-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FireflyHelper, rewrite ParticleHelper to use lambdas, bump versio…
…n to 3.4.4
- Loading branch information
Showing
15 changed files
with
574 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/turniplabs/halplibe/helper/FireflyHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package turniplabs.halplibe.helper; | ||
|
||
import net.minecraft.client.entity.fx.EntityFireflyFX; | ||
import net.minecraft.core.block.BlockLanternFirefly; | ||
import turniplabs.halplibe.mixin.accessors.EntityFireflyFXAccessor; | ||
import turniplabs.halplibe.util.FireflyColor; | ||
import turniplabs.halplibe.util.IFireflyColor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
abstract public class FireflyHelper { | ||
public static final List<FireflyColor> registeredColors = new ArrayList<>(); | ||
|
||
public static void createColor(FireflyColor fireflyColor) { | ||
registeredColors.add(fireflyColor); | ||
} | ||
|
||
public static void setColor(BlockLanternFirefly block, FireflyColor color) { | ||
((IFireflyColor) block).halplibe$setColor(color); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/turniplabs/halplibe/mixin/accessors/EntityFXAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package turniplabs.halplibe.mixin.accessors; | ||
|
||
import net.minecraft.client.entity.fx.EntityFX; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(value = EntityFX.class, remap = false) | ||
public interface EntityFXAccessor { | ||
@Accessor | ||
void setParticleRed(float particleRed); | ||
|
||
@Accessor | ||
void setParticleGreen(float particleGreen); | ||
|
||
@Accessor | ||
void setParticleBlue(float particleBlue); | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/turniplabs/halplibe/mixin/accessors/EntityFireflyFXAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package turniplabs.halplibe.mixin.accessors; | ||
|
||
import net.minecraft.client.entity.fx.EntityFireflyFX; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(value = EntityFireflyFX.class, remap = false) | ||
public interface EntityFireflyFXAccessor { | ||
@Accessor | ||
void setMidR(float midR); | ||
|
||
@Accessor | ||
void setMidG(float midG); | ||
|
||
@Accessor | ||
void setMidB(float midB); | ||
|
||
@Mutable | ||
@Accessor | ||
void setMinR(float minR); | ||
|
||
@Mutable | ||
@Accessor | ||
void setMinG(float minG); | ||
|
||
@Mutable | ||
@Accessor | ||
void setMinB(float minB); | ||
|
||
@Accessor | ||
void setMaxR(float maxR); | ||
|
||
@Accessor | ||
void setMaxG(float maxG); | ||
|
||
@Accessor | ||
void setMaxB(float maxB); | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/turniplabs/halplibe/mixin/mixins/BlockLanternFireflyMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package turniplabs.halplibe.mixin.mixins; | ||
|
||
import net.minecraft.core.block.Block; | ||
import net.minecraft.core.block.BlockLanternFirefly; | ||
import net.minecraft.core.block.material.Material; | ||
import net.minecraft.core.entity.animal.EntityFireflyCluster; | ||
import net.minecraft.core.enums.EnumFireflyColor; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import turniplabs.halplibe.util.FireflyColor; | ||
import turniplabs.halplibe.util.IFireflyColor; | ||
|
||
@Debug(export = true) | ||
@Mixin(value = BlockLanternFirefly.class, remap = false) | ||
abstract public class BlockLanternFireflyMixin extends Block implements IFireflyColor { | ||
@Mutable | ||
@Shadow | ||
@Final | ||
private EnumFireflyColor color; | ||
|
||
public BlockLanternFireflyMixin(String key, int id, Material material) { | ||
super(key, id, material); | ||
} | ||
|
||
@Unique | ||
private FireflyColor halplibe$color; | ||
|
||
@Unique | ||
public void halplibe$setColor(FireflyColor color) { | ||
halplibe$color = color; | ||
} | ||
|
||
@Inject(method = "<init>", at = @At(value = "TAIL")) | ||
private void constructorInject(String key, int id, EnumFireflyColor colour, CallbackInfo ci) { | ||
color = null; | ||
} | ||
|
||
@Redirect(method = "randomDisplayTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/enums/EnumFireflyColor;getParticleName()Ljava/lang/String;")) | ||
private String redirectParticleName(EnumFireflyColor instance) { | ||
return halplibe$color.getParticleName(); | ||
} | ||
|
||
@Redirect( | ||
method = "onBlockDestroyedByPlayer", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/core/entity/animal/EntityFireflyCluster;setColor(Lnet/minecraft/core/enums/EnumFireflyColor;)V" | ||
) | ||
) | ||
private void redirectColor(EntityFireflyCluster instance, EnumFireflyColor colour) { | ||
((IFireflyColor) instance).halplibe$setColor(halplibe$color); | ||
} | ||
} |
Oops, something went wrong.