Skip to content

Commit e8d9c73

Browse files
committed
Some mess up + document update
1 parent c9b3757 commit e8d9c73

File tree

6 files changed

+36
-4
lines changed

6 files changed

+36
-4
lines changed

Diff for: TestMixin/src/main/java/com/dragoncommissions/testmixin/TestMixin.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.dragoncommissions.mixbukkit.MixBukkit;
44
import com.dragoncommissions.mixbukkit.addons.AutoMapper;
55
import com.dragoncommissions.mixbukkit.api.MixinPlugin;
6-
import com.dragoncommissions.testmixin.mixins.EDragonArrowShieldRemover;
76
import lombok.SneakyThrows;
87
import org.bukkit.event.Listener;
98
import org.bukkit.plugin.java.JavaPlugin;
@@ -16,7 +15,8 @@ public class TestMixin extends JavaPlugin implements Listener {
1615
public void onEnable() {
1716
MixinPlugin plugin = MixBukkit.registerMixinPlugin(this, AutoMapper.getMappingAsStream());
1817

19-
EDragonArrowShieldRemover.register(plugin);
18+
// EDragonArrowShieldRemover.register(plugin);
19+
2020
}
2121

2222

Diff for: TestMixin/src/main/java/com/dragoncommissions/testmixin/mixins/EDragonArrowShieldRemover.java renamed to TestMixin/src/main/java/com/dragoncommissions/testmixin/examples/EDragonArrowShieldRemover.java

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dragoncommissions.testmixin.mixins;
1+
package com.dragoncommissions.testmixin.examples;
22

33
import com.dragoncommissions.mixbukkit.api.MixinPlugin;
44
import com.dragoncommissions.mixbukkit.api.action.impl.MActionInsertShellCode;
@@ -22,6 +22,29 @@ public static void register(MixinPlugin plugin) {
2222
), AbstractDragonSittingPhase.class, "onHurt", float.class, DamageSource.class, float.class);
2323
}
2424

25+
/*
26+
Original Sourcecode of AbstractDragonSittingPhase#onHurt(DamageSource, float):
27+
public float onHurt(DamageSource var0, float var1) {
28+
if (var0.getDirectEntity() instanceof AbstractArrow) { // A
29+
var0.getDirectEntity().setSecondsOnFire(1); // B
30+
return 0.0F; // C
31+
} else {
32+
return super.onHurt(var0, var1);
33+
}
34+
}
35+
36+
37+
this code prevents players from attacking dragons with arrows while dragon is in sitting phase.
38+
There's no way to make it possible with vanilla bukkit API other than tracing down EnderDragon#hurt(EnderDragonPart, DamageSource, float)
39+
Well, that's not a good idea.
40+
41+
In this case, Mixin is the best solution (if you are fine making it only works with 1 version)
42+
43+
In this mixin, it modifies the original onHurt method, makes a call to EDragonArrowShieldRemover#onHurt(AbstractDragonSittingPhase, DamageSource, float, CallbackInfo)
44+
It checks of the damage source is arrow, if it is then it will return the original damage instead of 0 (0 is returned in vanilla if source is arrow)
45+
Since the "A" will never be called, the arrow will never bounce off again.
46+
*/
47+
2548
public static void onHurt(AbstractDragonSittingPhase phase, DamageSource source, float damage, CallbackInfo info) {
2649
if (source.getDirectEntity() instanceof AbstractArrow) {
2750
info.setReturned(true);

Diff for: docs/Getting Started.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Getting Started
22
In this tutorial, I'll be teaching you how to start coding your first mixin plugin!
3+
## Out of date
4+
This document is outdated. Require an update.
35

46
## Requirements
57
1. Some basic Java knowledge

Diff for: pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
<maven.compiler.target>8</maven.compiler.target>
1515
</properties>
1616

17+
<repositories>
18+
<repository>
19+
<id>spigot-repo</id>
20+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
21+
</repository>
22+
</repositories>
23+
1724
<dependencies>
1825
<dependency>
1926
<groupId>org.spigotmc</groupId>

Diff for: readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ In theory, it should work from Java 8 ~ Java latest, Linux & Windows & MacOS, bu
99
Minecraft version is not limited, but it will result in mapping different
1010

1111
## Basic Usage
12+
(Please check `docs/Getting Started.md` for more information)
1213
### Mapping
1314
#### Method 1. Use Spigot's Members Mapping
1415
If you want to make things easy/fast/good/great/simple, you can use this method.

Diff for: src/main/java/com/dragoncommissions/mixbukkit/api/action/impl/MActionMethodReplacer.java

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import java.lang.reflect.Method;
1414

15-
@SuppressWarnings("Untested")
1615
public class MActionMethodReplacer implements MixinAction {
1716

1817
private Method handler;

0 commit comments

Comments
 (0)