-
Notifications
You must be signed in to change notification settings - Fork 7
Wand Focus: Isolation #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d24be54
463733b
d81f8a6
8665a90
78f8e15
62a3d8d
d8eff99
77ba83c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
|
|
||
| package talonos.blightbuster.client; | ||
|
|
||
| import net.minecraft.client.Minecraft; | ||
| import net.minecraft.entity.player.EntityPlayer; | ||
|
|
||
| import org.lwjgl.opengl.GL11; | ||
|
|
||
| public class StabilizedNodeRenderer { | ||
|
|
||
| // i have zero idea how any of this works so if you come across this in the future please don't judge me | ||
| // or ask me to explain it because i can't | ||
|
|
||
| public static void render(int bx, int by, int bz, float partialTicks) { | ||
| final float radius = 0.6f; | ||
| Minecraft mc = Minecraft.getMinecraft(); | ||
| EntityPlayer p = mc.thePlayer; | ||
| if (p == null) return; | ||
|
|
||
| double px = p.lastTickPosX + (p.posX - p.lastTickPosX) * partialTicks; | ||
| double py = p.lastTickPosY + (p.posY - p.lastTickPosY) * partialTicks; | ||
| double pz = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * partialTicks; | ||
|
|
||
| double x = bx - px + 0.5; | ||
| double y = by - py + 0.5; | ||
| double z = bz - pz + 0.5; | ||
|
|
||
| float t = (System.currentTimeMillis() % 200000L) / 1000f; | ||
|
|
||
| GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); | ||
| GL11.glPushMatrix(); | ||
|
|
||
| GL11.glTranslated(x, y, z); | ||
|
|
||
| GL11.glDisable(GL11.GL_TEXTURE_2D); | ||
| GL11.glDisable(GL11.GL_ALPHA_TEST); | ||
| GL11.glDisable(GL11.GL_LIGHTING); | ||
| GL11.glDisable(GL11.GL_CULL_FACE); | ||
| GL11.glEnable(GL11.GL_BLEND); | ||
| GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); | ||
| GL11.glDepthMask(false); | ||
|
|
||
| renderShimmeringLayers(t, radius); | ||
|
|
||
| GL11.glPopMatrix(); | ||
| GL11.glPopAttrib(); | ||
| GL11.glColor4f(1f, 1f, 1f, 1f); | ||
| } | ||
|
|
||
| private static void renderShimmeringLayers(float time, float radius) { | ||
| GL11.glMatrixMode(GL11.GL_TEXTURE); | ||
| GL11.glPushMatrix(); | ||
| GL11.glLoadIdentity(); | ||
| GL11.glTranslatef(time * 0.04f, time * 0.02f, 0); | ||
| GL11.glScalef(1.8f, 1.8f, 1); | ||
| GL11.glMatrixMode(GL11.GL_MODELVIEW); | ||
|
|
||
| GL11.glColor4f(0.8f, 0.9f, 1f, 1f); | ||
| drawSphere(radius, 24, 24); | ||
|
|
||
| GL11.glMatrixMode(GL11.GL_TEXTURE); | ||
| GL11.glPopMatrix(); | ||
| GL11.glMatrixMode(GL11.GL_MODELVIEW); | ||
|
|
||
| GL11.glMatrixMode(GL11.GL_TEXTURE); | ||
| GL11.glPushMatrix(); | ||
| GL11.glLoadIdentity(); | ||
| GL11.glTranslatef(time * -0.10f, time * 0.06f, 0); | ||
| GL11.glScalef(3.5f, 3.5f, 1); | ||
| GL11.glMatrixMode(GL11.GL_MODELVIEW); | ||
|
|
||
| GL11.glColor4f(0.9f, 1f, 1f, 1f); | ||
| drawSphere(radius, 24, 24); | ||
|
|
||
| GL11.glMatrixMode(GL11.GL_TEXTURE); | ||
| GL11.glPopMatrix(); | ||
| GL11.glMatrixMode(GL11.GL_MODELVIEW); | ||
| } | ||
|
|
||
| private static void drawSphere(float radius, int stacks, int slices) { | ||
| float time = (System.currentTimeMillis() % 100000) / 1000f; | ||
|
|
||
| for (int i = 0; i < stacks; i++) { | ||
| float lat0 = (float) Math.PI * (-0.5f + (float) i / stacks); | ||
| float z0 = (float) Math.sin(lat0); | ||
| float zr0 = (float) Math.cos(lat0); | ||
|
|
||
| float lat1 = (float) Math.PI * (-0.5f + (float) (i + 1) / stacks); | ||
| float z1 = (float) Math.sin(lat1); | ||
| float zr1 = (float) Math.cos(lat1); | ||
|
|
||
| GL11.glBegin(GL11.GL_TRIANGLE_STRIP); | ||
| for (int j = 0; j <= slices; j++) { | ||
| float lng = 2f * (float) Math.PI * (j == slices ? 0 : j) / slices; | ||
| float x = (float) Math.cos(lng); | ||
| float y = (float) Math.sin(lng); | ||
|
|
||
| float bolt0 = Math.abs((float) Math.sin(time * 12 + lng * 6 + lat0 * 9)); | ||
| float bolt1 = Math.abs((float) Math.sin(time * 12 + lng * 6 + lat1 * 9)); | ||
| bolt0 = (float) Math.pow(bolt0, 2.2); | ||
| bolt1 = (float) Math.pow(bolt1, 2.2); | ||
|
|
||
| GL11.glColor4f(0.7f, 0.9f, 1f, bolt0 * 0.35f); | ||
| GL11.glVertex3f(radius * x * zr0, radius * z0, radius * y * zr0); | ||
|
|
||
| GL11.glColor4f(0.7f, 0.9f, 1f, bolt1 * 0.35f); | ||
| GL11.glVertex3f(radius * x * zr1, radius * z1, radius * y * zr1); | ||
| } | ||
| GL11.glEnd(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,83 @@ | ||||||
| package talonos.blightbuster.items; | ||||||
|
|
||||||
| import net.minecraft.client.renderer.texture.IIconRegister; | ||||||
| import net.minecraft.creativetab.CreativeTabs; | ||||||
| import net.minecraft.entity.EntityLivingBase; | ||||||
| import net.minecraft.entity.player.EntityPlayer; | ||||||
| import net.minecraft.item.ItemStack; | ||||||
| import net.minecraft.util.MovingObjectPosition; | ||||||
|
|
||||||
| import cpw.mods.fml.common.registry.GameRegistry; | ||||||
| import cpw.mods.fml.relauncher.Side; | ||||||
| import cpw.mods.fml.relauncher.SideOnly; | ||||||
| import talonos.blightbuster.BBStrings; | ||||||
| import talonos.blightbuster.BlightBuster; | ||||||
| import talonos.blightbuster.lib.INodeIsolated; | ||||||
| import thaumcraft.api.aspects.Aspect; | ||||||
| import thaumcraft.api.aspects.AspectList; | ||||||
| import thaumcraft.api.wands.FocusUpgradeType; | ||||||
| import thaumcraft.api.wands.ItemFocusBasic; | ||||||
| import thaumcraft.common.items.wands.ItemWandCasting; | ||||||
|
|
||||||
| public class ItemIsolationFocus extends ItemFocusBasic { | ||||||
|
|
||||||
| public ItemIsolationFocus() { | ||||||
| setUnlocalizedName(BlightBuster.MODID + "_" + BBStrings.isolationFocusName); | ||||||
| GameRegistry.registerItem(this, BlightBuster.MODID + ":" + BBStrings.isolationFocusName); | ||||||
| setCreativeTab(CreativeTabs.tabMaterials); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other BB items are in Thaum's creative tab.
Suggested change
|
||||||
| setTextureName(BlightBuster.MODID + ":" + BBStrings.isolationFocusName); | ||||||
| } | ||||||
|
|
||||||
| public boolean onEntitySwing(EntityLivingBase entity, ItemStack stack) { | ||||||
| if ((stack.getItem() instanceof ItemWandCasting wand && entity instanceof EntityPlayer player)) { | ||||||
| MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(player.worldObj, player, true); | ||||||
| if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { | ||||||
| if (!(player.worldObj | ||||||
| .getTileEntity(mop.blockX, mop.blockY, mop.blockZ) instanceof INodeIsolated node)) { | ||||||
| return super.onEntitySwing(player, stack); | ||||||
| } | ||||||
| if (!wand.consumeAllVis(stack, player, this.getVisCost(stack), true, false)) { | ||||||
| return super.onEntitySwing(player, stack); | ||||||
| } | ||||||
| node.setIsolated(!node.isIsolated()); | ||||||
| } | ||||||
| } | ||||||
| return super.onEntitySwing(entity, stack); | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public int getActivationCooldown(ItemStack focusstack) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still triggers the cooldown for every left click, even when not actually used to isolate a node. I thought maybe adding |
||||||
| return 500; | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public boolean onFocusBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { | ||||||
| return player.getEntityWorld() | ||||||
| .getTileEntity(x, y, z) instanceof INodeIsolated && !player.isSneaking(); | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| @SideOnly(Side.CLIENT) | ||||||
| public void registerIcons(IIconRegister register) { | ||||||
| this.itemIcon = register.registerIcon(this.getIconString()); | ||||||
| this.icon = register.registerIcon(this.getIconString()); | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public int getFocusColor(ItemStack arg0) { | ||||||
| return 0x5a00cf; | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack itemstack, int rank) { | ||||||
|
|
||||||
| return new FocusUpgradeType[0]; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No Frugal? |
||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public AspectList getVisCost(ItemStack itemstack) { | ||||||
| AspectList cost = new AspectList(); | ||||||
| cost.add(Aspect.ORDER, 20); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0.2 Ordo seems way too cheap. Not using terra or aer when those are the aspects used to craft it also seems odd. Maybe 100 (for 1 vis) Terra and 50 (0.5 vis) Aer would be a bit better. It should also probably be configurable. |
||||||
| return cost; | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package talonos.blightbuster.lib; | ||
|
|
||
| public interface INodeIsolated { | ||
|
|
||
| void setIsolated(boolean stable); | ||
|
|
||
| boolean isIsolated(); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -27,7 +27,7 @@ public enum Mixins { | |||||
| DISABLE_SHEEP_SPREAD(new Builder("Disables tainted sheep taint spread").addTargetedMod(TargetedMod.THAUMCRAFT) | ||||||
| .setSide(Side.BOTH) | ||||||
| .setPhase(Phase.LATE) | ||||||
| .addMixinClasses("MixinTileNode") | ||||||
| .addMixinClasses("MixinTileNode_Taint") | ||||||
| .setApplyIf(() -> true)), | ||||||
| DISABLE_CREEPER_EXPLOSION(new Builder("Disabled tainted creeper explosions").addTargetedMod(TargetedMod.THAUMCRAFT) | ||||||
| .setSide(Side.BOTH) | ||||||
|
|
@@ -43,7 +43,25 @@ public enum Mixins { | |||||
| .setSide(Side.BOTH) | ||||||
| .setPhase(Phase.LATE) | ||||||
| .addMixinClasses("MixinUtils") | ||||||
| .setApplyIf(() -> true)); | ||||||
| .setApplyIf(() -> true)), | ||||||
| ADD_TILE_RENDERER(new Builder("Add custom node tile renderer").addTargetedMod(TargetedMod.THAUMCRAFT) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| .setSide(Side.CLIENT) | ||||||
| .setPhase(Phase.LATE) | ||||||
| .addMixinClasses("MixinTileNodeRenderer") | ||||||
| .setApplyIf(() -> true)), | ||||||
| ADD_NODE_STABILIZER(new Builder("Add node isolation functionality").addTargetedMod(TargetedMod.THAUMCRAFT) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably also be renamed to match the focus's actual name. |
||||||
| .setSide(Side.BOTH) | ||||||
| .setPhase(Phase.LATE) | ||||||
| .addMixinClasses("MixinTileNode_Isolate") | ||||||
| .setApplyIf(() -> true)), | ||||||
| STOP_STABILIZER_FOCUS_BREAK( | ||||||
| new Builder("Prevent isolation focus from breaking nodes").addTargetedMod(TargetedMod.THAUMCRAFT) | ||||||
| .setSide(Side.BOTH) | ||||||
| .setPhase(Phase.LATE) | ||||||
| .addMixinClasses("MixinItemWandCasting_FocusNoBreak") | ||||||
| .setApplyIf(() -> true)), | ||||||
|
|
||||||
| ; | ||||||
|
|
||||||
| private final List<String> mixinClasses; | ||||||
| private final List<TargetedMod> targetedMods; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package talonos.blightbuster.mixins.late; | ||
|
|
||
| import net.minecraft.entity.EntityLivingBase; | ||
|
|
||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
|
|
||
| import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
| import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
| import com.llamalad7.mixinextras.sugar.Local; | ||
|
|
||
| import talonos.blightbuster.items.ItemIsolationFocus; | ||
| import thaumcraft.api.wands.ItemFocusBasic; | ||
| import thaumcraft.common.items.wands.ItemWandCasting; | ||
|
|
||
| @Mixin(ItemWandCasting.class) | ||
| public class MixinItemWandCasting_FocusNoBreak { | ||
|
|
||
| @WrapOperation( | ||
| method = "onBlockStartBreak", | ||
| at = @At( | ||
| value = "INVOKE", | ||
| target = "Lthaumcraft/common/items/wands/WandManager;isOnCooldown(Lnet/minecraft/entity/EntityLivingBase;)Z", | ||
| remap = false), | ||
| remap = false) | ||
| private boolean preventBreakIfFocusActive(EntityLivingBase entityLiving, Operation<Boolean> original, | ||
| @Local(name = "focus") ItemFocusBasic focus) { | ||
| if (focus instanceof ItemIsolationFocus) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you could also check for the Purity focus here and remove ItemPurityFocus::onFocusBlockStartBreak. |
||
| return entityLiving.isSneaking(); // gets inverted in the original method, so will prevent breaking when not | ||
| // sneaking | ||
| } | ||
| return original.call(entityLiving); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be renamed to IsolatedNodeRenderer to match the focus name