Compare commits

..
12 Commits
Author SHA1 Message Date
Martin Robertz 0272517b10 update 2025-10-01 18:21:40 +02:00
koolkrafter5 8782f7c6a7 Merge #74 to master (#75) 2025-09-29 20:17:30 +02:00
sisyphussy 58676ab46d Fix certain block interactions + redstone mode (#72) 2025-09-25 19:34:14 +02:00
sisyphussy 2127d30d16 Dynamism bug fixes (#71) 2025-09-22 09:04:52 +02:00
Martin Robertz 5268737e2e update 2025-09-21 21:33:20 +02:00
sisyphussy c075644243 Fix crash (#70) 2025-09-21 21:32:25 +02:00
boubou19 e95d6c870c fix build (#69) 2025-09-21 17:32:34 +02:00
Martin Robertz 6d278db79d update 2025-09-21 16:40:29 +02:00
sisyphussyandMartin Robertz 4f2618d03b Dynamism Tablet Rewrite (#65)
Co-authored-by: Martin Robertz <[email protected]>
2025-09-21 16:33:05 +02:00
sisyphussy c2cbc66645 Fix failed build tests (#67) 2025-09-18 19:09:54 +02:00
Martin Robertz df4a8cfca9 update 2025-09-18 10:21:03 +02:00
sisyphussy 00e831c20f Item Placement Mirror Fixes (#66) 2025-09-18 00:58:42 +02:00
18 changed files with 759 additions and 607 deletions

No files matched your search

+13 -13
View File
@@ -1,29 +1,29 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:Baubles-Expanded:2.1.9-GTNH:dev')
api('com.github.GTNewHorizons:Baubles-Expanded:2.1.15-GTNH:dev')
api('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-665-GTNH:api')
api('com.github.GTNewHorizons:ThaumicBoots:1.4.9:dev') {
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-690-GTNH:api')
api('com.github.GTNewHorizons:ThaumicBoots:1.4.14:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'Electro-Magic-Tools'
exclude module: 'Baubles'
}
compileOnly('com.github.GTNewHorizons:Botania:1.12.21-GTNH:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:Botania:1.13.0-GTNH:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:EnderCore:0.4.8:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:EnderIO:2.9.21:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:EnderStorage:1.7.5:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:waila:1.8.12:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:TinkersConstruct:1.13.46-GTNH:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.6.7:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:CodeChickenCore:1.4.3:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.11.16-GTNH:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:EnderIO:2.9.26:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:EnderStorage:1.7.7:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:waila:1.9.0:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:TinkersConstruct:1.14.0-GTNH:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.6.8:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.11.19-GTNH:api') {transitive=false}
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:api') {transitive=false}
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.51.410:dev") {transitive=false}
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.02:dev") {exclude group: 'com.github.GTNewHorizons', module: 'ThaumicTinkerer'}
compileOnly('curse.maven:computercraft-67504:2269339')
compileOnly('curse.maven:cofh-core-69162:2388751')
runtimeOnly('com.github.GTNewHorizons:TCNEIAdditions:1.5.1:dev') {
runtimeOnly('com.github.GTNewHorizons:TCNEIAdditions:1.5.4:dev') {
exclude module: 'Baubles'
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ developmentEnvironmentUserName = Developer
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
enableModernJavaSyntax = true
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
+11
View File
@@ -1,4 +1,15 @@
// Add any additional repositories for your dependencies here
repositories {
exclusiveContent {
forRepository {
maven {
name = 'glease'
url = 'https://maven.glease.net/repos/releases/'
}
}
filter {
includeGroup('net.glease')
}
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.41'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.43'
}
@@ -8,7 +8,6 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
@@ -17,63 +16,54 @@ import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import thaumic.tinkerer.common.ThaumicTinkerer;
import thaumic.tinkerer.common.item.kami.ItemPlacementMirror;
import thaumic.tinkerer.common.registry.TTRegistry;
public final class PlacementMirrorPredictionRenderer {
RenderBlocks blockRender = new RenderBlocks();
private final RenderBlocks blockRender;
public PlacementMirrorPredictionRenderer() {
this.blockRender = new RenderBlocks();
blockRender.useInventoryTint = false;
}
@SubscribeEvent
public void onWorldRenderLast(RenderWorldLastEvent event) {
World world = Minecraft.getMinecraft().theWorld;
List<EntityPlayer> playerEntities = world.playerEntities;
for (EntityPlayer player : playerEntities) {
ItemStack currentStack = player.getCurrentEquippedItem();
if (currentStack != null
&& currentStack.getItem()
== ThaumicTinkerer.registry.getFirstItemFromClass(ItemPlacementMirror.class)
&& ItemPlacementMirror.getBlock(currentStack) != Blocks.air) {
if (currentStack != null && currentStack.getItem() == TTRegistry.itemPlacementMirror) {
renderPlayerLook(player, currentStack);
}
}
}
private void renderPlayerLook(EntityPlayer player, ItemStack stack) {
ChunkCoordinates[] coords = ItemPlacementMirror.getBlocksToPlace(stack, player);
if (ItemPlacementMirror.hasBlocks(stack, player, coords)) {
ItemStack block = new ItemStack(
ItemPlacementMirror.getBlock(stack),
1,
ItemPlacementMirror.getBlockMeta(stack));
ChunkCoordinates lastCoords = new ChunkCoordinates(0, 0, 0);
GL11.glPushMatrix();
Block requiredBlock = ItemPlacementMirror.getBlock(stack);
if (requiredBlock == null) return;
int requiredMetadata = ItemPlacementMirror.getBlockMeta(stack);
List<ChunkCoordinates> coords = ItemPlacementMirror.getBlocksToPlace(stack, player);
if (ItemPlacementMirror.hasBlocks(player, requiredBlock, requiredMetadata, coords.size())) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 0.6F);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
for (ChunkCoordinates coord : coords) {
renderBlockAt(block, coord, lastCoords);
lastCoords = coord;
renderBlockAt(requiredBlock, requiredMetadata, coord);
}
GL11.glPopMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
}
}
private void renderBlockAt(ItemStack block, ChunkCoordinates pos, ChunkCoordinates last) {
if (block.getItem() == null) return;
private void renderBlockAt(Block block, int metadata, ChunkCoordinates pos) {
GL11.glPushMatrix();
GL11.glTranslated(
pos.posX + 0.5 - RenderManager.renderPosX,
pos.posY + 0.5 - RenderManager.renderPosY,
pos.posZ + 0.5 - RenderManager.renderPosZ);
GL11.glColor4f(1F, 1F, 1F, 0.6F);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
blockRender.useInventoryTint = false;
blockRender.renderBlockAsItem(Block.getBlockFromItem(block.getItem()), block.getItemDamage(), 1F);
blockRender.renderBlockAsItem(block, metadata, 1F);
GL11.glPopMatrix();
}
}
@@ -3,7 +3,6 @@ package thaumic.tinkerer.client.render.item;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
@@ -19,8 +18,6 @@ import thaumic.tinkerer.common.item.ItemInfusedSeeds;
*/
public class RenderGenericSeeds implements IItemRenderer {
private static RenderItem renderItem = new RenderItem();
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
if (type == ItemRenderType.INVENTORY) return true;
@@ -2,7 +2,6 @@ package thaumic.tinkerer.client.render.item;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
@@ -16,8 +15,6 @@ import thaumic.tinkerer.common.item.ItemMobDisplay;
public class RenderMobDisplay implements IItemRenderer {
private static RenderItem renderItem = new RenderItem();
@Override
public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) {
return true;
@@ -1,9 +1,7 @@
package thaumic.tinkerer.client.render.item.kami;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;
@@ -15,9 +13,6 @@ import thaumic.tinkerer.common.item.kami.ItemPlacementMirror;
public class RenderPlacementMirror implements IItemRenderer {
RenderItem render = new RenderItem();
ItemRenderer renderer = new ItemRenderer(Minecraft.getMinecraft());
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
@@ -69,6 +64,7 @@ public class RenderPlacementMirror implements IItemRenderer {
break;
}
case INVENTORY: {
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
GL11.glRotatef(45f, 0f, 1f, 0f);
GL11.glScalef(1.5f, 1.8f, 1.8f);
@@ -77,6 +73,7 @@ public class RenderPlacementMirror implements IItemRenderer {
renderItem(ItemRenderType.EQUIPPED, item, data);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_ALPHA_TEST);
break;
}
default:
@@ -47,12 +47,18 @@ public class RenderTileAnimationTablet extends TileEntitySpecialRenderer {
int rotation = meta == 2 ? 270 : meta == 3 ? 90 : meta == 4 ? 0 : 180;
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glPushMatrix();
GL11.glTranslated(d0, d1, d2);
renderOverlay(tile, overlayCenter, -1, false, false, 0.65, 0.13F, 0F);
if (tile.leftClick) renderOverlay(tile, overlayLeft, 1, false, true, 1, 0.13F, 0F);
else renderOverlay(tile, overlayRight, 1, false, true, 1, 0.131F, 0F);
renderOverlay(tile, overlayIndent, 0, false, false, 0.5F, 0.13F, rotation + 90F);
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_LIGHTING);
renderOverlay(tile, overlayCenter, -1, false, 0.65, 0.13F, partialTicks);
if (tile.leftClick) renderOverlay(tile, overlayLeft, 1, true, 1, 0.13F, partialTicks);
else renderOverlay(tile, overlayRight, 1, true, 1, 0.131F, partialTicks);
renderIndents(tile, rotation + 90F);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthMask(true);
GL11.glRotatef(rotation, 0F, 1F, 0F);
GL11.glTranslated(0.1, 0.2 + Math.cos(System.currentTimeMillis() / 600D) / 18F, 0.5);
@@ -60,9 +66,10 @@ public class RenderTileAnimationTablet extends TileEntitySpecialRenderer {
GL11.glTranslatef(translations[0], translations[1], translations[2]);
GL11.glScalef(0.8F, 0.8F, 0.8F);
GL11.glTranslatef(0.5F, 0F, 0.5F);
GL11.glRotatef(tile.swingProgress, 0F, 0F, 1F);
float swingProgress = tile.getRenderSwingProgress(partialTicks);
GL11.glRotatef(swingProgress, 0F, 0F, 1F);
GL11.glTranslatef(-0.5F, 0F, -0.5F);
GL11.glTranslatef(-tile.swingProgress / 250F, tile.swingProgress / 1000F, 0F);
GL11.glTranslatef(-swingProgress / 250F, swingProgress / 1000F, 0F);
GL11.glRotatef((float) Math.cos(System.currentTimeMillis() / 400F) * 5F, 1F, 0F, 1F);
renderItem(tile);
GL11.glPopMatrix();
@@ -72,6 +79,8 @@ public class RenderTileAnimationTablet extends TileEntitySpecialRenderer {
ItemStack stack = tablet.getStackInSlot(0);
if (stack != null) {
EntityItem entityitem = new EntityItem(tablet.getWorldObj(), 0.0D, 0.0D, 0.0D, stack);
entityitem.worldObj = tablet.getWorldObj();
int stackSize = entityitem.getEntityItem().stackSize;
entityitem.getEntityItem().stackSize = 1;
entityitem.hoverStart = 0.0F;
GL11.glPushMatrix();
@@ -81,25 +90,24 @@ public class RenderTileAnimationTablet extends TileEntitySpecialRenderer {
RenderItem.renderInFrame = true;
RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
RenderItem.renderInFrame = false;
GL11.glPopMatrix();
entityitem.getEntityItem().stackSize = stackSize;
}
}
private void renderOverlay(TileAnimationTablet tablet, ResourceLocation texture, int rotationMod,
boolean useLighting, boolean useBlend, double size, float height, float forceDeg) {
private void renderOverlay(TileAnimationTablet tablet, ResourceLocation texture, int rotationMod, boolean useBlend,
double size, float height, float partialTicks) {
Minecraft mc = ClientHelper.minecraft();
mc.renderEngine.bindTexture(texture);
GL11.glPushMatrix();
GL11.glDepthMask(false);
if (!useLighting) GL11.glDisable(GL11.GL_LIGHTING);
if (useBlend) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
GL11.glTranslatef(0.5F, height, 0.5F);
float deg = rotationMod == 0 ? forceDeg : (float) (tablet.ticksExisted * rotationMod % 360F);
float deg = (tablet.getTicksExisted(partialTicks) * rotationMod % 360F);
GL11.glRotatef(deg, 0F, 1F, 0F);
GL11.glColor4f(1F, 1F, 1F, 1F);
Tessellator tess = Tessellator.instance;
double size1 = size / 2;
double size2 = -size1;
@@ -109,8 +117,33 @@ public class RenderTileAnimationTablet extends TileEntitySpecialRenderer {
tess.addVertexWithUV(size1, 0, size2, 1, 0);
tess.addVertexWithUV(size2, 0, size2, 0, 0);
tess.draw();
GL11.glDepthMask(true);
if (!useLighting) GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
private void renderIndents(TileAnimationTablet tablet, float forceDeg) {
Minecraft mc = ClientHelper.minecraft();
mc.renderEngine.bindTexture(overlayIndent);
GL11.glPushMatrix();
GL11.glTranslatef(0.5F, (float) 0.13, 0.5F);
GL11.glRotatef(forceDeg, 0F, 1F, 0F);
Tessellator tess = Tessellator.instance;
final double size1 = 0.25;
final double size2 = -0.25;
tess.startDrawingQuads();
tess.addVertexWithUV(size2, 0, size1, 0, 1);
tess.addVertexWithUV(size1, 0, size1, 1, 1);
tess.addVertexWithUV(size1, 0, size2, 1, 0);
tess.addVertexWithUV(size2, 0, size2, 0, 0);
tess.draw();
int acceleration = tablet.getWorldAcceleratorBonus();
if (acceleration != 0) {
GL11.glRotatef(90, -1, 0, 0);
GL11.glScalef(0.02f, -0.02f, 0.02f);
final String s = 'x' + Integer.toString(acceleration);
final int width = mc.fontRenderer.getStringWidth(s);
GL11.glTranslatef(-width / 2f, 10f + mc.fontRenderer.FONT_HEIGHT / 2f, 0);
mc.fontRenderer.drawString(s, 0, 0, 0xFFFFFF);
}
GL11.glPopMatrix();
}
}
@@ -57,6 +57,7 @@ public class ThaumicTinkerer {
public static TTCommonProxy proxy;
public static boolean isBootsActive = false;
public static boolean gtLoaded;
public static final String BOOTS = "thaumicboots";
public static CommonProxy tcProxy;
@@ -80,6 +81,7 @@ public class ThaumicTinkerer {
if (Loader.isModLoaded(BOOTS)) {
isBootsActive = true;
}
gtLoaded = Loader.isModLoaded("gregtech");
}
@EventHandler
@@ -44,6 +44,7 @@ import thaumic.tinkerer.common.block.tile.tablet.TileAnimationTablet;
import thaumic.tinkerer.common.lib.LibBlockNames;
import thaumic.tinkerer.common.lib.LibGuiIDs;
import thaumic.tinkerer.common.lib.LibResearch;
import thaumic.tinkerer.common.registry.TTRegistry;
import thaumic.tinkerer.common.registry.ThaumicTinkererArcaneRecipe;
import thaumic.tinkerer.common.registry.ThaumicTinkererRecipe;
import thaumic.tinkerer.common.research.IRegisterableResearch;
@@ -98,37 +99,32 @@ public class BlockAnimationTablet extends BlockModContainer {
TileAnimationTablet tablet = (TileAnimationTablet) par1World.getTileEntity(par2, par3, par4);
if (tablet != null) {
if (tablet.getIsBreaking()) {}
ItemStack itemstack = tablet.heldItem;
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
for (int j1 = 0; j1 < tablet.getSizeInventory(); ++j1) {
ItemStack itemstack = tablet.getStackInSlot(j1);
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World
.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
if (k1 > itemstack.stackSize) k1 = itemstack.stackSize;
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World
.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
itemstack.stackSize -= k1;
entityitem = new EntityItem(
par1World,
par2 + f,
par3 + f1,
par4 + f2,
new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3;
if (k1 > itemstack.stackSize) k1 = itemstack.stackSize;
itemstack.stackSize -= k1;
entityitem = new EntityItem(
par1World,
par2 + f,
par3 + f1,
par4 + f2,
new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3;
if (itemstack.hasTagCompound()) entityitem.getEntityItem()
.setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
if (itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
}
@@ -142,6 +138,8 @@ public class BlockAnimationTablet extends BlockModContainer {
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) {
if (par1World.isRemote) return;
TileEntity te = par1World.getTileEntity(par2, par3, par4);
if (!(te instanceof TileAnimationTablet tablet) || !tablet.redstone) return;
boolean power = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)
|| par1World.isBlockIndirectlyGettingPowered(par2, par3 + 1, par4);
@@ -149,9 +147,10 @@ public class BlockAnimationTablet extends BlockModContainer {
boolean on = (meta & 8) != 0;
if (power && !on) {
par1World.scheduleBlockUpdate(par2, par3, par4, this, tickRate(par1World));
par1World.setBlockMetadataWithNotify(par2, par3, par4, meta | 8, 4);
} else if (!power && on) par1World.setBlockMetadataWithNotify(par2, par3, par4, meta & 7, 4);
} else if (!power && on) {
par1World.setBlockMetadataWithNotify(par2, par3, par4, meta & 7, 4);
}
}
@Override
@@ -159,37 +158,17 @@ public class BlockAnimationTablet extends BlockModContainer {
return 1;
}
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
TileEntity tile = par1World.getTileEntity(par2, par3, par4);
if (tile != null && tile instanceof TileAnimationTablet) {
TileAnimationTablet tablet = (TileAnimationTablet) tile;
if (tablet.redstone && tablet.swingProgress == 0) {
tablet.findEntities(tablet.getTargetLoc());
tablet.initiateSwing();
par1World.addBlockEvent(
par2,
par3,
par4,
ThaumicTinkerer.registry.getFirstBlockFromClass(BlockAnimationTablet.class),
0,
0);
}
}
}
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer,
int par6, float par7, float par8, float par9) {
if (!par1World.isRemote) {
TileEntity tile = par1World.getTileEntity(par2, par3, par4);
if (tile != null) {
TileAnimationTablet tablet = (TileAnimationTablet) tile;
if (tile instanceof TileAnimationTablet tablet) {
if (par5EntityPlayer.getCurrentEquippedItem() != null
&& par5EntityPlayer.getCurrentEquippedItem().getItem() instanceof ItemWandCasting) {
int meta = par1World.getBlockMetadata(par2, par3, par4);
boolean activated = (meta & 8) != 0;
if (!activated && !tablet.getIsBreaking() && tablet.swingProgress == 0) {
if (!activated && !tablet.getIsBreaking() && tablet.isIdle()) {
par1World.setBlockMetadataWithNotify(par2, par3, par4, meta == 5 ? 2 : meta + 1, 1 | 2);
par1World.playSoundEffect(par2, par3, par4, "thaumcraft:tool", 0.6F, 1F);
} else par5EntityPlayer
@@ -268,10 +247,9 @@ public class BlockAnimationTablet extends BlockModContainer {
-8,
2,
4,
new ItemStack(ThaumicTinkerer.registry.getFirstBlockFromClass(BlockAnimationTablet.class))).setWarp(1)
.setParents(LibResearch.KEY_MAGNETS).setPages(
new ResearchPage("0"),
ResearchHelper.arcaneRecipePage(LibResearch.KEY_ANIMATION_TABLET));
new ItemStack(TTRegistry.dynamismTablet)).setWarp(1).setParents(LibResearch.KEY_MAGNETS).setPages(
new ResearchPage("0"),
ResearchHelper.arcaneRecipePage(LibResearch.KEY_ANIMATION_TABLET));
}
@Override
@@ -279,7 +257,7 @@ public class BlockAnimationTablet extends BlockModContainer {
return new ThaumicTinkererArcaneRecipe(
LibResearch.KEY_ANIMATION_TABLET,
LibResearch.KEY_ANIMATION_TABLET,
new ItemStack(ThaumicTinkerer.registry.getFirstBlockFromClass(BlockAnimationTablet.class)),
new ItemStack(TTRegistry.dynamismTablet),
new AspectList().add(Aspect.AIR, 25).add(Aspect.ORDER, 15).add(Aspect.FIRE, 10),
"GIG",
"ICI",
@@ -13,76 +13,180 @@ package thaumic.tinkerer.common.block.tile.tablet;
import java.util.UUID;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import com.mojang.authlib.GameProfile;
import thaumcraft.common.lib.FakeThaumcraftPlayer;
public final class TabletFakePlayer extends FakePlayer {
public class TabletFakePlayer extends FakeThaumcraftPlayer {
private final TileAnimationTablet tablet;
TileAnimationTablet tablet;
public TabletFakePlayer(TileAnimationTablet tablet) { // ,String name) {
public TabletFakePlayer(TileAnimationTablet tablet) {
super(
tablet.getWorldObj(),
(WorldServer) tablet.getWorldObj(),
new GameProfile(UUID.fromString("a8f026a0-135b-11e4-9191-0800200c9a66"), "[ThaumcraftTablet]"));
// super(tablet.getWorldObj(),"[ThaumcraftTablet]");
this.tablet = tablet;
}
@Override
public void setDead() {
inventory.clearInventory(null, -1);
super.setDead();
}
@Override
public void openGui(Object mod, int modGuiId, World world, int x, int y, int z) {
// NO-OP
this.playerNetServerHandler = new DummyNetHandlerPlayServer(MinecraftServer.getServer(), this);
this.width = 0;
this.height = 0;
this.boundingBox.setBounds(this.posX, this.posY, this.posZ, this.posX, this.posY, this.posZ);
this.rotationPitch = -15;
}
@Override
public void onUpdate() {
capabilities.isCreativeMode = false;
posX = tablet.xCoord + 0.5;
posY = tablet.yCoord + 1.6;
posZ = tablet.zCoord + 0.5;
if (riddenByEntity != null) riddenByEntity.ridingEntity = null;
if (ridingEntity != null) ridingEntity.riddenByEntity = null;
riddenByEntity = null;
ridingEntity = null;
this.posX = tablet.xCoord + 0.5f;
this.posY = tablet.yCoord + 0.5f;
this.posZ = tablet.zCoord + 0.5f;
this.inventory.currentItem = 0;
motionX = motionY = motionZ = 0;
setHealth(20);
isDead = false;
this.capabilities.isCreativeMode = false;
int meta = tablet.getBlockMetadata() & 7;
int rotation = meta == 2 ? 180 : meta == 3 ? 0 : meta == 4 ? 90 : -90;
rotationYaw = rotationYawHead = rotation;
rotationPitch = -15;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (i != inventory.currentItem) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack != null) {
entityDropItem(stack, 1.0f);
inventory.setInventorySlotContents(i, null);
}
rotationYaw = rotationYawHead = rotation;
// Drop everything except for held item
for (int i = 1; i < inventory.getSizeInventory(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack != null) {
entityDropItem(stack, 0);
inventory.setInventorySlotContents(i, null);
}
}
syncSlots();
}
@Override
public void addChatMessage(IChatComponent var1) {}
public void syncSlots() {
this.inventory.mainInventory[0] = tablet.heldItem;
}
// Copied from Minecraft and PlayerControllerMP
public boolean sendUseItem(ItemStack stack) {
if (!ForgeEventFactory.onPlayerInteract(this, PlayerInteractEvent.Action.RIGHT_CLICK_AIR, 0, 0, 0, -1, worldObj)
.isCanceled()) {
int i = stack.stackSize;
ItemStack itemstack1 = stack.useItemRightClick(worldObj, this);
if (itemstack1 == stack && itemstack1.stackSize == i) {
return false;
}
inventory.mainInventory[0] = itemstack1;
if (itemstack1.stackSize <= 0) {
inventory.mainInventory[0] = null;
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this, itemstack1));
}
return true;
}
return false;
}
// copied from PlayerController#onPlayerRightClick
public boolean onPlayerRightClick(ItemStack stack, int x, int y, int z, int side, float f, float f1, float f2) {
Item item = stack.getItem();
if (item != null && item.onItemUseFirst(stack, this, worldObj, x, y, z, side, f, f1, f2)) {
return true;
}
Block block = worldObj.getBlock(x, y, z);
if (block.onBlockActivated(worldObj, x, y, z, this, side, f, f1, f2)) {
return true;
}
if (!stack.tryPlaceItemIntoWorld(this, worldObj, x, y, z, side, f, f1, f2)) {
return false;
}
if (stack.stackSize <= 0) {
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this, stack));
}
return true;
}
@Override
public ChunkCoordinates getPlayerCoordinates() {
return new ChunkCoordinates(tablet.xCoord, tablet.yCoord, tablet.zCoord);
}
@Override
protected boolean isMovementBlocked() {
return true;
}
@Override
public boolean canBePushed() {
return false;
}
@Override
public boolean canBeCollidedWith() {
return false;
}
@Override
public void setPosition(double x, double y, double z) {
// NO-OP (the position is set at creation)
}
@Override
public void setDead() {
// NO-OP (this should never happen...?)
}
@Override
public void mountEntity(Entity entityIn) {
// NO-OP
}
@Override
public void setHealth(float p_70606_1_) {
// NO-OP
}
@Override
public void onLivingUpdate() {
// NO-OP
}
@Override
public void addChatMessage(IChatComponent var1) {
// NO-OP
}
@Override
public void addChatComponentMessage(IChatComponent chatmessagecomponent) {
// NO-OP
}
private static final class DummyNetHandlerPlayServer extends NetHandlerPlayServer {
public DummyNetHandlerPlayServer(MinecraftServer server, FakePlayer player) {
super(server, new NetworkManager(false), player);
}
@Override
public void onNetworkTick() {
// NO-OP
}
@Override
public void sendPacket(Packet packetIn) {
// NO-OP
}
}
}
File diff suppressed because it is too large. Load diff
@@ -292,4 +292,12 @@ public class ItemCleansingTalisman extends ItemBase implements IBauble {
public String getItemName() {
return LibItemNames.CLEANSING_TALISMAN;
}
@Override
public boolean getIsRepairable(ItemStack talisman, ItemStack material) {
if (material != null
&& material.getItem() == ThaumicTinkerer.registry.getFirstItemFromClass(ItemDarkQuartz.class))
return true;
return super.getIsRepairable(talisman, material);
}
}
@@ -34,6 +34,7 @@ import thaumic.tinkerer.common.item.kami.tool.ToolHandler;
import thaumic.tinkerer.common.lib.LibItemNames;
import thaumic.tinkerer.common.lib.LibResearch;
import thaumic.tinkerer.common.registry.ItemKamiBase;
import thaumic.tinkerer.common.registry.TTRegistry;
import thaumic.tinkerer.common.registry.ThaumicTinkererInfusionRecipe;
import thaumic.tinkerer.common.registry.ThaumicTinkererRecipe;
import thaumic.tinkerer.common.research.IRegisterableResearch;
@@ -42,9 +43,6 @@ import thaumic.tinkerer.common.research.ResearchHelper;
public class ItemPlacementMirror extends ItemKamiBase {
@Deprecated
private static final String TAG_BLOCK_ID = "blockID";
private static final String TAG_BLOCK_NAME = "blockName";
private static final String TAG_BLOCK_META = "blockMeta";
private static final String TAG_SIZE = "size";
@@ -56,40 +54,39 @@ public class ItemPlacementMirror extends ItemKamiBase {
setMaxStackSize(1);
}
public static boolean hasBlocks(ItemStack stack, EntityPlayer player, ChunkCoordinates[] blocks) {
public static boolean hasBlocks(EntityPlayer player, Block requiredBlock, int requiredMetadata,
int requiredAmount) {
if (player.capabilities.isCreativeMode) return true;
int required = blocks.length;
Item requiredItem = Item.getItemFromBlock(requiredBlock);
int current = 0;
ItemStack reqStack = new ItemStack(getBlock(stack), 1, getBlockMeta(stack));
List<ItemStack> talismansToCheck = new ArrayList<>();
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
if (stackInSlot != null && stackInSlot.getItem() == reqStack.getItem()
&& stackInSlot.getItemDamage() == reqStack.getItemDamage()) {
current += stackInSlot.stackSize;
if (current >= required) return true;
if (stackInSlot == null) continue;
Item itemInSlot = stackInSlot.getItem();
if (itemInSlot == requiredItem) {
if (stackInSlot.getItemDamage() == requiredMetadata) {
current += stackInSlot.stackSize;
if (current >= requiredAmount) return true;
}
} else if (itemInSlot == TTRegistry.itemBlackHoleTalisman) {
if (ItemBlockTalisman.getBlock(stackInSlot) == requiredBlock
&& ItemBlockTalisman.getBlockMeta(stackInSlot) == requiredMetadata) {
talismansToCheck.add(stackInSlot);
}
}
if (stackInSlot != null
&& stackInSlot.getItem() == ThaumicTinkerer.registry.getFirstItemFromClass(ItemBlockTalisman.class))
talismansToCheck.add(stackInSlot);
}
for (ItemStack talisman : talismansToCheck) {
Block block = ItemBlockTalisman.getBlock(talisman);
int meta = ItemBlockTalisman.getBlockMeta(talisman);
current += ItemBlockTalisman.getBlockCount(talisman);
if (Item.getItemFromBlock(block) == reqStack.getItem() && meta == reqStack.getItemDamage()) {
current += ItemBlockTalisman.getBlockCount(talisman);
if (current >= required) return true;
}
if (current >= requiredAmount) return true;
}
return false;
}
public static ChunkCoordinates[] getBlocksToPlace(ItemStack stack, EntityPlayer player) {
public static List<ChunkCoordinates> getBlocksToPlace(ItemStack stack, EntityPlayer player) {
List<ChunkCoordinates> coords = new ArrayList<>();
MovingObjectPosition pos = ToolHandler.raytraceFromEntity(player.worldObj, player, true, 5);
if (pos != null) {
@@ -124,7 +121,7 @@ public class ItemPlacementMirror extends ItemKamiBase {
}
}
return coords.toArray(new ChunkCoordinates[coords.size()]);
return coords;
}
private static void setSize(ItemStack stack, int size) {
@@ -135,16 +132,8 @@ public class ItemPlacementMirror extends ItemKamiBase {
return ItemNBTHelper.getInt(stack, TAG_SIZE, 3) | 1;
}
@Deprecated
public static int getBlockID(ItemStack stack) {
return ItemNBTHelper.getInt(stack, TAG_BLOCK_ID, 0);
}
public static Block getBlock(ItemStack stack) {
Block block = Block.getBlockFromName(getBlockName(stack));
if (block == Blocks.air) block = Block.getBlockById(getBlockID(stack));
return block;
return Block.getBlockFromName(getBlockName(stack));
}
public static String getBlockName(ItemStack stack) {
@@ -182,16 +171,20 @@ public class ItemPlacementMirror extends ItemKamiBase {
}
public void placeAllBlocks(ItemStack stack, EntityPlayer player) {
ChunkCoordinates[] blocksToPlace = getBlocksToPlace(stack, player);
if (!hasBlocks(stack, player, blocksToPlace)) return;
Block requiredBlock = getBlock(stack);
if (requiredBlock == null) return;
int requiredMetadata = getBlockMeta(stack);
List<ChunkCoordinates> blocksToPlace = getBlocksToPlace(stack, player);
if (!hasBlocks(player, requiredBlock, requiredMetadata, blocksToPlace.size())) return;
ItemStack stackToPlace = new ItemStack(getBlock(stack), 1, getBlockMeta(stack));
for (ChunkCoordinates coords : blocksToPlace) placeBlockAndConsume(player, stackToPlace, coords);
ItemStack stackToPlace = new ItemStack(requiredBlock, 1, requiredMetadata);
for (ChunkCoordinates coords : blocksToPlace) {
placeBlockAndConsume(player, stackToPlace, coords);
}
player.worldObj.playSoundAtEntity(player, "thaumcraft:wand", 1F, 1F);
}
private void placeBlockAndConsume(EntityPlayer player, ItemStack blockToPlace, ChunkCoordinates coords) {
if (blockToPlace.getItem() == null) return;
player.worldObj.setBlock(
coords.posX,
coords.posY,
@@ -213,8 +206,7 @@ public class ItemPlacementMirror extends ItemKamiBase {
return;
}
if (stackInSlot != null
&& stackInSlot.getItem() == ThaumicTinkerer.registry.getFirstItemFromClass(ItemBlockTalisman.class))
if (stackInSlot != null && stackInSlot.getItem() == TTRegistry.itemBlackHoleTalisman)
talismansToCheck.add(stackInSlot);
}
@@ -20,7 +20,10 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import thaumic.tinkerer.client.lib.LibResources;
import thaumic.tinkerer.common.ThaumicTinkerer;
import thaumic.tinkerer.common.block.BlockAnimationTablet;
import thaumic.tinkerer.common.core.handler.ModCreativeTab;
import thaumic.tinkerer.common.item.kami.ItemBlockTalisman;
import thaumic.tinkerer.common.item.kami.ItemPlacementMirror;
import thaumic.tinkerer.common.research.IRegisterableResearch;
public class TTRegistry {
@@ -31,6 +34,10 @@ public class TTRegistry {
private ArrayList<Class> blockClasses = new ArrayList<>();
private HashMap<Class, ArrayList<Block>> blockRegistry = new HashMap<>();
public static Block dynamismTablet;
public static Item itemPlacementMirror;
public static Item itemBlackHoleTalisman;
public void registerClasses() {
try {
ClassPath classPath = ClassPath.from(this.getClass().getClassLoader());
@@ -171,6 +178,10 @@ public class TTRegistry {
}
}
}
dynamismTablet = ThaumicTinkerer.registry.getFirstBlockFromClass(BlockAnimationTablet.class);
itemBlackHoleTalisman = getFirstItemFromClass(ItemBlockTalisman.class);
itemPlacementMirror = getFirstItemFromClass(ItemPlacementMirror.class);
}
public ArrayList<Item> getItemFromClass(Class clazz) {
@@ -0,0 +1,13 @@
package thaumic.tinkerer.mixins.early;
import net.minecraft.server.management.ItemInWorldManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ItemInWorldManager.class)
public interface AccessorItemInWorldManager {
@Accessor
int getDurabilityRemainingOnBlock();
}
@@ -99,8 +99,8 @@ public class ThaumicTLoaderContainer extends DummyModContainer implements IFMLLo
@Override
public List<String> getMixins(Set<String> loadedCoreMods) {
if (!FMLLaunchHandler.side().isClient()) {
return Collections.emptyList();
return Collections.singletonList("AccessorItemInWorldManager");
}
return Collections.singletonList("renderer.MixinRenderBlocks");
return Arrays.asList("renderer.MixinRenderBlocks", "AccessorItemInWorldManager");
}
}