mirror of
https://github.com/GTNewHorizons/ThaumicTinkerer.git
synced 2026-11-28 16:06:07 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c71c62daf0 | ||
|
|
9900cdb1db | ||
|
|
2655f15c31 |
No files matched your search
@@ -3,9 +3,9 @@ name: Build and test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main, release/** ]
|
||||
branches: [ master, main ]
|
||||
push:
|
||||
branches: [ master, main, release/** ]
|
||||
branches: [ master, main ]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
|
||||
+3
-2
@@ -3,7 +3,7 @@
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:Baubles-Expanded:2.2.25-GTNH:dev')
|
||||
api('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') {transitive=false}
|
||||
api('com.github.GTNewHorizons:Applied-Energistics-2-NH:1.0.2:api')
|
||||
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-999-GTNH:api')
|
||||
api('com.github.GTNewHorizons:ThaumicBoots:1.5.13:dev') {transitive=false}
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:Botania:1.13.39-GTNH:dev') {transitive=false}
|
||||
@@ -12,13 +12,14 @@ dependencies {
|
||||
compileOnly('com.github.GTNewHorizons:EnderStorage:1.8.9:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:waila:1.19.34:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:TinkersConstruct:1.14.120-GTNH:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:ForgeMultipart:2.0.0:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.7.18:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:CodeChickenCore:1.4.22:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.64-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.54.242:dev") {exclude group: 'com.github.GTNewHorizons', module: 'ThaumicTinkerer'}
|
||||
compileOnly('curse.maven:computercraft-67504:2269339')
|
||||
compileOnly('curse.maven:cofh-core-69162:2388751')
|
||||
compileOnly('com.github.GTNewHorizons:Dashboard:1.0.11:api')
|
||||
|
||||
// For testing purposes
|
||||
//runtimeOnlyNonPublishable("com.github.GTNewHorizons:Electro-Magic-Tools:1.7.25:dev")
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
package thaumic.tinkerer.client.core.handler;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import com.gtnewhorizons.dashboard.api.HudBounds;
|
||||
import com.gtnewhorizons.dashboard.api.HudElement;
|
||||
import com.gtnewhorizons.dashboard.api.HudRegistry;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumic.tinkerer.client.core.handler.kami.SoulHeartClientHandler;
|
||||
import thaumic.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
|
||||
import thaumic.tinkerer.common.core.handler.ConfigHandler;
|
||||
|
||||
/**
|
||||
* Lets players move, resize and hide the Dislocation focus box, the Kami tool mode text and the soul hearts in
|
||||
* Dashboard's HUD editor. The only class using Dashboard, so only call it while Dashboard is loaded.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final class DashboardHud {
|
||||
|
||||
private static final int ITEM_SIZE = 18;
|
||||
private static final int TEXT_PADDING = 4;
|
||||
private static final int TOOL_MODE_OFFSET = 72;
|
||||
private static final int SOUL_HEARTS_WIDTH = 81;
|
||||
private static final int SOUL_HEARTS_HEIGHT = 9;
|
||||
private static final int SAMPLE_SOUL_HP = 20;
|
||||
private static final int BOX_COLOR = 0x66000000;
|
||||
private static final int TEXT_COLOR = 0xFFAA00;
|
||||
|
||||
private static final HudElement DISLOCATION_FOCUS = new HudElement(
|
||||
"thaumictinkerer:dislocation_focus",
|
||||
DashboardHud::getDislocationBounds);
|
||||
|
||||
private static final HudElement TOOL_MODE = new HudElement(
|
||||
"thaumictinkerer:tool_mode",
|
||||
DashboardHud::getToolModeBounds);
|
||||
|
||||
private static final HudElement SOUL_HEARTS = new HudElement(
|
||||
"thaumictinkerer:soul_hearts",
|
||||
DashboardHud::getSoulHeartsBounds);
|
||||
|
||||
private static final RenderItem RENDER_ITEM = new RenderItem();
|
||||
|
||||
private DashboardHud() {}
|
||||
|
||||
/** The tool mode text and soul hearts only exist with Kami turned on. */
|
||||
public static void register(boolean kami) {
|
||||
DISLOCATION_FOCUS.setPreview(
|
||||
(screenWidth, screenHeight) -> HudRegistry
|
||||
.render(DISLOCATION_FOCUS, () -> drawDislocationPreview(screenWidth, screenHeight)));
|
||||
HudRegistry.register(DISLOCATION_FOCUS);
|
||||
if (!kami) {
|
||||
return;
|
||||
}
|
||||
TOOL_MODE.setPreview(
|
||||
(screenWidth, screenHeight) -> HudRegistry
|
||||
.render(TOOL_MODE, () -> drawToolModePreview(screenWidth, screenHeight)));
|
||||
SOUL_HEARTS.setPreview(
|
||||
(screenWidth, screenHeight) -> HudRegistry.render(SOUL_HEARTS, DashboardHud::drawSoulHeartsPreview));
|
||||
HudRegistry.register(TOOL_MODE);
|
||||
HudRegistry.register(SOUL_HEARTS);
|
||||
}
|
||||
|
||||
// False means the player hid the element, so skip drawing it and do not call endRender()
|
||||
|
||||
public static boolean beginDislocationFocus(ScaledResolution resolution) {
|
||||
return HudRegistry.beginRender(DISLOCATION_FOCUS, resolution);
|
||||
}
|
||||
|
||||
public static boolean beginToolMode(ScaledResolution resolution) {
|
||||
return HudRegistry.beginRender(TOOL_MODE, resolution);
|
||||
}
|
||||
|
||||
public static boolean beginSoulHearts(ScaledResolution resolution) {
|
||||
return HudRegistry.beginRender(SOUL_HEARTS, resolution);
|
||||
}
|
||||
|
||||
public static void endRender() {
|
||||
HudRegistry.endRender();
|
||||
}
|
||||
|
||||
/** Next to Thaumcraft's wand dial: the block's icon, with the text in the small font beside it. */
|
||||
private static HudBounds getDislocationBounds(int screenWidth, int screenHeight) {
|
||||
int y = Config.dialBottom ? screenHeight - 70 : 50;
|
||||
int textWidth = getSmallTextWidth(StatCollector.translateToLocal("ttmisc.focusDislocation.tooltip"));
|
||||
return new HudBounds(TEXT_PADDING - 1, y - 1, ITEM_SIZE + 1 + textWidth + TEXT_PADDING, ITEM_SIZE + 1);
|
||||
}
|
||||
|
||||
/** Centered above the hotbar, a little above the held item's name. */
|
||||
private static HudBounds getToolModeBounds(int screenWidth, int screenHeight) {
|
||||
int width = Minecraft.getMinecraft().fontRenderer.getStringWidth(getToolModeText());
|
||||
return new HudBounds((screenWidth - width) / 2, screenHeight - TOOL_MODE_OFFSET, width, 9);
|
||||
}
|
||||
|
||||
/** Above the food bar, at soulHeart.height, higher while the air bubbles show. */
|
||||
private static HudBounds getSoulHeartsBounds(int screenWidth, int screenHeight) {
|
||||
int y = screenHeight - ConfigHandler.soulHeartHeight;
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null && player.getAir() < 300) {
|
||||
y -= 10;
|
||||
}
|
||||
return new HudBounds(screenWidth / 2 + 10, y, SOUL_HEARTS_WIDTH, SOUL_HEARTS_HEIGHT);
|
||||
}
|
||||
|
||||
private static String getToolModeText() {
|
||||
String text = ToolModeHUDHandler.getTooltip();
|
||||
return text == null || text.isEmpty() ? StatCollector.translateToLocal("ttmisc.mode.pick.1") : text;
|
||||
}
|
||||
|
||||
private static int getSmallTextWidth(String text) {
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
boolean unicode = font.getUnicodeFlag();
|
||||
font.setUnicodeFlag(true);
|
||||
int width = font.getStringWidth(text);
|
||||
font.setUnicodeFlag(unicode);
|
||||
return width;
|
||||
}
|
||||
|
||||
/** Like the real one: a chest in the box, the text in the small font beside it. */
|
||||
private static void drawDislocationPreview(int screenWidth, int screenHeight) {
|
||||
HudBounds bounds = getDislocationBounds(screenWidth, screenHeight);
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
FontRenderer font = mc.fontRenderer;
|
||||
String text = StatCollector.translateToLocal("ttmisc.focusDislocation.tooltip");
|
||||
int x = bounds.x + 1;
|
||||
int y = bounds.y + 1;
|
||||
Gui.drawRect(bounds.x, bounds.y, x + ITEM_SIZE, y + ITEM_SIZE, BOX_COLOR);
|
||||
Gui.drawRect(x + ITEM_SIZE, y, bounds.getRight(), y + 9, BOX_COLOR);
|
||||
boolean unicode = font.getUnicodeFlag();
|
||||
font.setUnicodeFlag(true);
|
||||
font.drawStringWithShadow(text, x + ITEM_SIZE + 2, y, TEXT_COLOR);
|
||||
font.setUnicodeFlag(unicode);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RENDER_ITEM.renderItemIntoGUI(font, mc.renderEngine, new ItemStack(Blocks.chest), x, y);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
|
||||
private static void drawToolModePreview(int screenWidth, int screenHeight) {
|
||||
HudBounds bounds = getToolModeBounds(screenWidth, screenHeight);
|
||||
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(getToolModeText(), bounds.x, bounds.y, TEXT_COLOR);
|
||||
}
|
||||
|
||||
/** The real drawing, with sample soul hearts for the moment. */
|
||||
private static void drawSoulHeartsPreview() {
|
||||
int realHp = SoulHeartClientHandler.clientPlayerHP;
|
||||
SoulHeartClientHandler.clientPlayerHP = SAMPLE_SOUL_HP;
|
||||
try {
|
||||
SoulHeartClientHandler.renderHUD(HudRegistry.getResolution(), Minecraft.getMinecraft().thePlayer, null);
|
||||
} finally {
|
||||
SoulHeartClientHandler.clientPlayerHP = realHp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import thaumcraft.api.wands.ItemFocusBasic;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
import thaumic.tinkerer.client.core.helper.ClientHelper;
|
||||
import thaumic.tinkerer.common.compat.LoadedMods;
|
||||
import thaumic.tinkerer.common.item.foci.ItemFocusDislocation;
|
||||
|
||||
public final class HUDHandler {
|
||||
@@ -49,7 +50,8 @@ public final class HUDHandler {
|
||||
|
||||
if (focus != null && focus instanceof ItemFocusDislocation) {
|
||||
ItemStack pickedBlock = ((ItemFocusDislocation) focus).getPickedBlock(item);
|
||||
if (pickedBlock != null) {
|
||||
if (pickedBlock != null
|
||||
&& (!LoadedMods.dashboardLoaded || DashboardHud.beginDislocationFocus(event.resolution))) {
|
||||
Gui.drawRect(xpos - 1, ypos - 1, xpos + 18, ypos + 18, 0x66000000);
|
||||
|
||||
FontRenderer font = ClientHelper.fontRenderer();
|
||||
@@ -87,6 +89,7 @@ public final class HUDHandler {
|
||||
ypos);
|
||||
}
|
||||
font.setUnicodeFlag(unicode);
|
||||
if (LoadedMods.dashboardLoaded) DashboardHud.endRender();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-1
@@ -24,7 +24,9 @@ import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import thaumic.tinkerer.client.core.handler.DashboardHud;
|
||||
import thaumic.tinkerer.client.lib.LibResources;
|
||||
import thaumic.tinkerer.common.compat.LoadedMods;
|
||||
import thaumic.tinkerer.common.core.handler.ConfigHandler;
|
||||
|
||||
public final class SoulHeartClientHandler {
|
||||
@@ -69,11 +71,25 @@ public final class SoulHeartClientHandler {
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void onDrawScreenPre(RenderGameOverlayEvent.Pre event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (event.type == RenderGameOverlayEvent.ElementType.HEALTH) {
|
||||
if (event.type == RenderGameOverlayEvent.ElementType.HEALTH && !LoadedMods.dashboardLoaded) {
|
||||
renderHUD(event.resolution, mc.thePlayer, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* With Dashboard, the soul hearts are drawn here instead of with the health bar, so they do not move or hide with
|
||||
* it.
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public void onDrawScreenPost(RenderGameOverlayEvent.Post event) {
|
||||
if (event.type == RenderGameOverlayEvent.ElementType.ALL && LoadedMods.dashboardLoaded
|
||||
&& clientPlayerHP > 0
|
||||
&& DashboardHud.beginSoulHearts(event.resolution)) {
|
||||
renderHUD(event.resolution, Minecraft.getMinecraft().thePlayer, null);
|
||||
DashboardHud.endRender();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) {
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import thaumic.tinkerer.client.core.handler.ClientTickHandler;
|
||||
import thaumic.tinkerer.client.core.handler.DashboardHud;
|
||||
import thaumic.tinkerer.common.compat.LoadedMods;
|
||||
|
||||
public final class ToolModeHUDHandler {
|
||||
|
||||
@@ -39,6 +41,10 @@ public final class ToolModeHUDHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTooltip() {
|
||||
return currentTooltip;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void clientTick() {
|
||||
if (tooltipDisplayTicks > 0) --tooltipDisplayTicks;
|
||||
@@ -62,7 +68,7 @@ public final class ToolModeHUDHandler {
|
||||
|
||||
if (opacity > 160) opacity = 160;
|
||||
|
||||
if (opacity > 0) {
|
||||
if (opacity > 0 && (!LoadedMods.dashboardLoaded || DashboardHud.beginToolMode(var5))) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -71,6 +77,7 @@ public final class ToolModeHUDHandler {
|
||||
var8.drawStringWithShadow(currentTooltip, tooltipStartX, tooltipStartY, color + (opacity << 24));
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
if (LoadedMods.dashboardLoaded) DashboardHud.endRender();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import thaumcraft.client.fx.ParticleEngine;
|
||||
import thaumic.tinkerer.client.core.handler.ClientTickHandler;
|
||||
import thaumic.tinkerer.client.core.handler.DashboardHud;
|
||||
import thaumic.tinkerer.client.core.handler.GemArmorKeyHandler;
|
||||
import thaumic.tinkerer.client.core.handler.HUDHandler;
|
||||
import thaumic.tinkerer.client.core.handler.kami.KamiArmorClientHandler;
|
||||
@@ -42,6 +43,7 @@ import thaumic.tinkerer.client.render.block.RenderInfusedCrops;
|
||||
import thaumic.tinkerer.client.render.block.RenderMagnet;
|
||||
import thaumic.tinkerer.client.render.block.RenderRepairer;
|
||||
import thaumic.tinkerer.client.render.block.kami.RenderWarpGate;
|
||||
import thaumic.tinkerer.client.render.item.RenderGenericSeeds;
|
||||
import thaumic.tinkerer.client.render.item.RenderMobDisplay;
|
||||
import thaumic.tinkerer.client.render.item.kami.RenderPlacementMirror;
|
||||
import thaumic.tinkerer.client.render.tile.RenderTileAnimationTablet;
|
||||
@@ -61,6 +63,7 @@ import thaumic.tinkerer.common.compat.FumeTool;
|
||||
import thaumic.tinkerer.common.compat.LoadedMods;
|
||||
import thaumic.tinkerer.common.core.handler.ConfigHandler;
|
||||
import thaumic.tinkerer.common.core.proxy.TTCommonProxy;
|
||||
import thaumic.tinkerer.common.item.ItemInfusedSeeds;
|
||||
import thaumic.tinkerer.common.item.ItemMobDisplay;
|
||||
import thaumic.tinkerer.common.item.kami.ItemPlacementMirror;
|
||||
import thaumic.tinkerer.common.item.kami.foci.ItemFocusShadowbeam;
|
||||
@@ -112,6 +115,8 @@ public final class TTClientProxy extends TTCommonProxy {
|
||||
if (ConfigHandler.showPlacementMirrorBlocks)
|
||||
MinecraftForge.EVENT_BUS.register(new PlacementMirrorPredictionRenderer());
|
||||
}
|
||||
|
||||
if (LoadedMods.dashboardLoaded) DashboardHud.register(ConfigHandler.enableKami);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -157,6 +162,9 @@ public final class TTClientProxy extends TTCommonProxy {
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ThaumicTinkerer.registry.getFirstItemFromClass(ItemMobDisplay.class),
|
||||
mobDisplayRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ThaumicTinkerer.registry.getFirstItemFromClass(ItemInfusedSeeds.class),
|
||||
new RenderGenericSeeds());
|
||||
|
||||
if (ConfigHandler.enableKami) {
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
|
||||
@@ -127,11 +127,11 @@ public class GuiEnchanting extends GuiContainer {
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if (par1GuiButton.id == 0) {
|
||||
ThaumicTinkerer.netHandler.sendToServer(new PacketEnchanterStartWorking());
|
||||
ThaumicTinkerer.netHandler.sendToServer(new PacketEnchanterStartWorking(enchanter));
|
||||
} else if (par1GuiButton.id <= 16) {
|
||||
GuiButtonEnchantment button = enchantButtons[par1GuiButton.id - 1];
|
||||
if (button != null && button.enchant != null)
|
||||
ThaumicTinkerer.netHandler.sendToServer(new PacketEnchanterAddEnchant(button.enchant.effectId, 0));
|
||||
if (button != null && button.enchant != null) ThaumicTinkerer.netHandler
|
||||
.sendToServer(new PacketEnchanterAddEnchant(enchanter, button.enchant.effectId, 0));
|
||||
} else {
|
||||
int type = (par1GuiButton.id - 17) % 3;
|
||||
int index = (par1GuiButton.id - 17) / 3;
|
||||
@@ -143,15 +143,20 @@ public class GuiEnchanting extends GuiContainer {
|
||||
Enchantment enchant = Enchantment.enchantmentsList[enchanter.enchantments.get(index)];
|
||||
|
||||
switch (type) {
|
||||
case 0 -> {
|
||||
ThaumicTinkerer.netHandler.sendToServer(new PacketEnchanterAddEnchant(enchant.effectId, -1));
|
||||
}
|
||||
case 1 -> {
|
||||
case 0: {
|
||||
ThaumicTinkerer.netHandler
|
||||
.sendToServer(new PacketEnchanterAddEnchant(enchant.effectId, level == 1 ? -1 : level - 1));
|
||||
.sendToServer(new PacketEnchanterAddEnchant(enchanter, enchant.effectId, -1));
|
||||
break;
|
||||
}
|
||||
case 2 -> {
|
||||
ThaumicTinkerer.netHandler.sendToServer(new PacketEnchanterAddEnchant(enchant.effectId, level + 1));
|
||||
case 1: {
|
||||
ThaumicTinkerer.netHandler.sendToServer(
|
||||
new PacketEnchanterAddEnchant(enchanter, enchant.effectId, level == 1 ? -1 : level - 1));
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
ThaumicTinkerer.netHandler
|
||||
.sendToServer(new PacketEnchanterAddEnchant(enchanter, enchant.effectId, level + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ public class GuiMobMagnet extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_MOB_MAGNET);
|
||||
|
||||
private int x, y;
|
||||
int x, y;
|
||||
|
||||
ItemStack stack = null;
|
||||
TileMobMagnet mobMagnet;
|
||||
|
||||
List<IRadioButton> radioButtons = new ArrayList<>();
|
||||
@@ -63,14 +64,11 @@ public class GuiMobMagnet extends GuiContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button instanceof IRadioButton rButton) {
|
||||
rButton.enableFromClick();
|
||||
} else {
|
||||
buttonList.get(0).enabled = !buttonList.get(0).enabled;
|
||||
}
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if (par1GuiButton instanceof IRadioButton) ((IRadioButton) par1GuiButton).enableFromClick();
|
||||
else buttonList.get(0).enabled = !buttonList.get(0).enabled;
|
||||
|
||||
mobMagnet.setAdult(buttonList.get(0).enabled);
|
||||
mobMagnet.adult = buttonList.get(0).enabled;
|
||||
|
||||
ThaumicTinkerer.netHandler.sendToServer(new PacketMobMagnetButton(mobMagnet));
|
||||
}
|
||||
@@ -82,7 +80,7 @@ public class GuiMobMagnet extends GuiContainer {
|
||||
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||
String adult = StatCollector.translateToLocal("ttmisc.adult");
|
||||
String child = StatCollector.translateToLocal("ttmisc.child");
|
||||
ItemStack stack = mobMagnet.getStackInSlot(0);
|
||||
stack = mobMagnet.getStackInSlot(0);
|
||||
|
||||
String filter;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumic.tinkerer.client.gui.button.GuiButtonRP;
|
||||
import thaumic.tinkerer.client.gui.button.GuiButtonRPRadio;
|
||||
import thaumic.tinkerer.client.gui.button.IRadioButton;
|
||||
@@ -29,6 +30,7 @@ public class GuiRemotePlacer extends GuiContainer {
|
||||
int x, y;
|
||||
List<IRadioButton> radioButtons = new ArrayList<>();
|
||||
TileRPlacer placer;
|
||||
Aspect aspectHovered = null;
|
||||
|
||||
public GuiRemotePlacer(TileRPlacer placer, InventoryPlayer inv) {
|
||||
super(new ContainerRemotePlacer(placer, inv));
|
||||
|
||||
@@ -21,14 +21,16 @@ public class GuiButtonMM extends GuiButton {
|
||||
|
||||
private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_MOB_MAGNET);
|
||||
|
||||
public GuiButtonMM(int buttonId, int x, int y, boolean enabled) {
|
||||
super(buttonId, x, y, 13, 13, "");
|
||||
public boolean enabled = false;
|
||||
|
||||
public GuiButtonMM(int par1, int par2, int par3, boolean enabled) {
|
||||
super(par1, par2, par3, 13, 13, "");
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
|
||||
if (visible) {
|
||||
if (enabled) {
|
||||
par1Minecraft.renderEngine.bindTexture(gui);
|
||||
int y = enabled ? 13 : 0;
|
||||
drawTexturedModalRect(xPosition, yPosition, 176, y, width, height);
|
||||
|
||||
@@ -17,8 +17,8 @@ public class GuiButtonMMRadio extends GuiButtonMM implements IRadioButton {
|
||||
|
||||
List<IRadioButton> linkedButtons;
|
||||
|
||||
public GuiButtonMMRadio(int buttonId, int x, int y, boolean enabled, List<IRadioButton> linkedButtons) {
|
||||
super(buttonId, x, y, enabled);
|
||||
public GuiButtonMMRadio(int par1, int par2, int par3, boolean enabled, List<IRadioButton> linkedButtons) {
|
||||
super(par1, par2, par3, enabled);
|
||||
this.linkedButtons = linkedButtons;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class GuiWarpGate extends GuiContainer {
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
((GuiButtonWG) par1GuiButton).enabled = !((GuiButtonWG) par1GuiButton).enabled;
|
||||
warpGate.setLocked(((GuiButtonWG) par1GuiButton).enabled);
|
||||
warpGate.locked = ((GuiButtonWG) par1GuiButton).enabled;
|
||||
|
||||
ThaumicTinkerer.netHandler.sendToServer(new PacketWarpGateButton(warpGate));
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import thaumic.tinkerer.common.network.packet.kami.PacketWarpGateTeleport;
|
||||
|
||||
public class GuiWarpGateDestinations extends GuiScreen {
|
||||
|
||||
private static final ResourceLocation enderField = new ResourceLocation("textures/entity/end_portal.png");
|
||||
private static ResourceLocation enderField = new ResourceLocation("textures/entity/end_portal.png");
|
||||
TileWarpGate warpGate;
|
||||
RenderItem render = new RenderItem();
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
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.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumic.tinkerer.common.item.ItemInfusedSeeds;
|
||||
|
||||
/**
|
||||
* Created by pixlepix on 8/6/14.
|
||||
*/
|
||||
public class RenderGenericSeeds implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
if (type == ItemRenderType.INVENTORY) return true;
|
||||
if (type == ItemRenderType.EQUIPPED) return true;
|
||||
if (type == ItemRenderType.ENTITY) return true;
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
if (helper == ItemRendererHelper.ENTITY_BOBBING) return true;
|
||||
if (helper == ItemRendererHelper.ENTITY_ROTATION) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack itemstack, Object... data) {
|
||||
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
ItemInfusedSeeds item = (ItemInfusedSeeds) itemstack.getItem();
|
||||
IIcon icon = item.getIconIndex(itemstack);
|
||||
Aspect aspect = item.getAspect(itemstack);
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
renderItemInInventory(itemstack, aspect, icon);
|
||||
} else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
renderItemInEquipped(itemstack, aspect, icon);
|
||||
} else {
|
||||
EntityItem entityItem = (EntityItem) data[1];
|
||||
if (entityItem.worldObj == null) {
|
||||
float angle = (Minecraft.getSystemTime() % 8000L) / 8000.0F * 360.0F;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.2F, -0.5F, 0.0F);
|
||||
renderItemAsEntity(itemstack, aspect, icon);
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
renderItemAsEntity(itemstack, aspect, icon);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
private void renderItemInInventory(ItemStack itemstack, Aspect aspect, IIcon icon) {
|
||||
setColorForAspect(aspect);
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
drawTexturedRectUV(0, 0, 0, 16, 16, icon);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
private void renderItemInEquipped(ItemStack itemstack, Aspect aspect, IIcon icon) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
setColorForAspect(aspect);
|
||||
ItemRenderer.renderItemIn2D(
|
||||
tessellator,
|
||||
icon.getMaxU(),
|
||||
icon.getMinV(),
|
||||
icon.getMinU(),
|
||||
icon.getMaxV(),
|
||||
icon.getIconWidth(),
|
||||
icon.getIconHeight(),
|
||||
0.0625F);
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
private void renderItemAsEntity(ItemStack itemstack, Aspect aspect, IIcon icon) {
|
||||
GL11.glPushMatrix();
|
||||
setColorForAspect(aspect);
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
drawTextureIn3D(icon);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void drawTextureIn3D(IIcon texture) {
|
||||
Tessellator tesselator = Tessellator.instance;
|
||||
float scale = 0.7F;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
ItemRenderer.renderItemIn2D(
|
||||
tesselator,
|
||||
texture.getMaxU(),
|
||||
texture.getMinV(),
|
||||
texture.getMinU(),
|
||||
texture.getMaxV(),
|
||||
texture.getIconWidth(),
|
||||
texture.getIconHeight(),
|
||||
.05F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void drawTexturedRectUV(float x, float y, float z, int w, int h, IIcon icon) {
|
||||
Tessellator tesselator = Tessellator.instance;
|
||||
tesselator.startDrawingQuads();
|
||||
tesselator.addVertexWithUV(x, y + h, z, icon.getMinU(), icon.getMaxV());
|
||||
tesselator.addVertexWithUV(x + w, y + h, z, icon.getMaxU(), icon.getMaxV());
|
||||
tesselator.addVertexWithUV(x + w, y, z, icon.getMaxU(), icon.getMinV());
|
||||
tesselator.addVertexWithUV(x, y, z, icon.getMinU(), icon.getMinV());
|
||||
tesselator.draw();
|
||||
}
|
||||
|
||||
private void setColorForAspect(Aspect aspect) {}
|
||||
}
|
||||
@@ -199,7 +199,8 @@ public class BlockRPlacer extends BlockCamo implements IWandable {
|
||||
@Override
|
||||
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
|
||||
TileEntity tile = par1World.getTileEntity(par2, par3, par4);
|
||||
if (tile instanceof TileRPlacer placer) {
|
||||
if (tile != null && tile instanceof TileRPlacer) {
|
||||
TileRPlacer placer = (TileRPlacer) tile;
|
||||
placer.receiveRedstonePulse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,12 +180,6 @@ public class TileMobMagnet extends TileMagnet implements IInventory, IMovableTil
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAdult(boolean adult) {
|
||||
this.adult = adult;
|
||||
this.markDirty();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return new String[] { "isPulling", "setPulling", "getSignal", "getAdultSearch", "setAdultSearch" };
|
||||
@@ -204,7 +198,9 @@ public class TileMobMagnet extends TileMagnet implements IInventory, IMovableTil
|
||||
}
|
||||
|
||||
private Object[] setAdultSearchImplementation(boolean argument) {
|
||||
setAdult(argument);
|
||||
|
||||
this.adult = argument;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class TileRPlacer extends TileCamo implements IInventory {
|
||||
super.readCustomNBT(cmp);
|
||||
|
||||
orientation = cmp.getInteger(TAG_ORIENTATION);
|
||||
blocks = Math.max(1, Math.min(cmp.getInteger(TAG_BLOCKS), 4));
|
||||
blocks = cmp.getInteger(TAG_BLOCKS);
|
||||
NBTTagList var2 = cmp.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
inventorySlots = new ItemStack[getSizeInventory()];
|
||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
|
||||
@@ -198,7 +198,7 @@ public class TileRPlacer extends TileCamo implements IInventory {
|
||||
z = this.zCoord;
|
||||
break;
|
||||
case 5:
|
||||
x = this.xCoord + this.blocks;
|
||||
x = this.xCoord - this.blocks;
|
||||
y = this.yCoord;
|
||||
z = this.zCoord;
|
||||
break;
|
||||
@@ -237,10 +237,4 @@ public class TileRPlacer extends TileCamo implements IInventory {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void setDistance(int distance) {
|
||||
blocks = Math.max(1, Math.min(distance, 4));
|
||||
this.markDirty();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import thaumic.tinkerer.common.block.tile.container.slot.SlotWand;
|
||||
|
||||
public class ContainerEnchanter extends ContainerPlayerInv {
|
||||
|
||||
public TileEnchanter enchanter;
|
||||
TileEnchanter enchanter;
|
||||
|
||||
public ContainerEnchanter(TileEnchanter enchanter, InventoryPlayer playerInv) {
|
||||
super(playerInv);
|
||||
@@ -38,14 +38,14 @@ public class ContainerEnchanter extends ContainerPlayerInv {
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = inventorySlots.get(par2);
|
||||
Slot var4 = (Slot) inventorySlots.get(par2);
|
||||
|
||||
if (var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
|
||||
if (var5 != null && var5.getItem() == Items.book) return null;
|
||||
|
||||
boolean wand = inventorySlots.get(1).isItemValid(var5);
|
||||
boolean wand = ((Slot) inventorySlots.get(1)).isItemValid(var5);
|
||||
|
||||
// noinspection ConstantConditions
|
||||
var3 = var5.copy();
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import thaumic.tinkerer.common.item.kami.ItemSkyPearl;
|
||||
|
||||
public class ContainerWarpGate extends ContainerPlayerInv {
|
||||
|
||||
public TileWarpGate gate;
|
||||
TileWarpGate gate;
|
||||
|
||||
public ContainerWarpGate(TileWarpGate gate, InventoryPlayer playerInv) {
|
||||
super(playerInv);
|
||||
@@ -44,7 +44,7 @@ public class ContainerWarpGate extends ContainerPlayerInv {
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = inventorySlots.get(par2);
|
||||
Slot var4 = (Slot) inventorySlots.get(par2);
|
||||
|
||||
if (var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
package thaumic.tinkerer.common.block.tile.kami;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -44,7 +46,8 @@ public class TileWarpGate extends TileEntity implements IInventory {
|
||||
int z = coords.posZ;
|
||||
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileWarpGate destGate) {
|
||||
if (tile != null && tile instanceof TileWarpGate) {
|
||||
TileWarpGate destGate = (TileWarpGate) tile;
|
||||
if (!destGate.locked) {
|
||||
player.worldObj.playSoundAtEntity(player, "thaumcraft:wand", 1F, 1F);
|
||||
|
||||
@@ -76,12 +79,12 @@ public class TileWarpGate extends TileEntity implements IInventory {
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
final AxisAlignedBB bbox = getTeleportRange();
|
||||
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(
|
||||
EntityPlayer.class,
|
||||
AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 1.5, zCoord + 1));
|
||||
|
||||
EntityPlayer player = ThaumicTinkerer.proxy.getClientPlayer();
|
||||
if (player != null && player.worldObj == this.worldObj
|
||||
&& player.isSneaking()
|
||||
&& player.boundingBox.intersectsWith(bbox)) {
|
||||
EntityPlayer clientPlayer = ThaumicTinkerer.proxy.getClientPlayer();
|
||||
for (EntityPlayer player : players) if (player != null && player == clientPlayer && player.isSneaking()) {
|
||||
player.openGui(
|
||||
ThaumicTinkerer.instance,
|
||||
LibGuiIDs.GUI_ID_WARP_GATE_DESTINATIONS,
|
||||
@@ -89,15 +92,12 @@ public class TileWarpGate extends TileEntity implements IInventory {
|
||||
xCoord,
|
||||
yCoord,
|
||||
zCoord);
|
||||
break;
|
||||
}
|
||||
|
||||
teleportedThisTick = false;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getTeleportRange() {
|
||||
return AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 1.5, zCoord + 1);
|
||||
}
|
||||
|
||||
public void teleportPlayer(EntityPlayer player, int index) {
|
||||
if (teleportedThisTick) return;
|
||||
|
||||
@@ -237,10 +237,4 @@ public class TileWarpGate extends TileEntity implements IInventory {
|
||||
super.onDataPacket(manager, packet);
|
||||
readCustomNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
public void setLocked(boolean locked) {
|
||||
this.locked = locked;
|
||||
this.markDirty();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class LoadedMods {
|
||||
public static final boolean bloodMagicLoaded = Loader.isModLoaded("BloodMagic");
|
||||
public static final boolean botaniaLoaded = Loader.isModLoaded("Botania");
|
||||
public static final boolean computerCraftLoaded = Loader.isModLoaded("ComputerCraft");
|
||||
public static final boolean dashboardLoaded = Loader.isModLoaded("dashboard");
|
||||
public static final boolean enderIOLoaded = Loader.isModLoaded("EnderIO");
|
||||
public static final boolean enderStorageLoaded = Loader.isModLoaded("EnderStorage");
|
||||
public static final boolean forgeMultipartLoaded = Loader.isModLoaded("ForgeMultipart");
|
||||
|
||||
@@ -21,7 +21,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
@@ -257,7 +256,8 @@ public class ItemCleansingTalisman extends ItemBase implements IBauble {
|
||||
|
||||
par1ItemStack.damageItem(damage, player);
|
||||
if (par1ItemStack.stackSize <= 0) {
|
||||
removeFromBaubles((EntityPlayer) player, par1ItemStack);
|
||||
// Slot 0 = talisman slot.
|
||||
BaublesApi.getBaubles((EntityPlayer) player).setInventorySlotContents(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,19 +300,4 @@ public class ItemCleansingTalisman extends ItemBase implements IBauble {
|
||||
return true;
|
||||
return super.getIsRepairable(talisman, material);
|
||||
}
|
||||
|
||||
private void removeFromBaubles(EntityPlayer player, ItemStack itemStack) {
|
||||
IInventory baubles = BaublesApi.getBaubles(player);
|
||||
for (int i = 0; i < baubles.getSizeInventory(); i++) {
|
||||
// BaublesApi calls "onWornTick" with a reference to the ItemStack, so != is correct here
|
||||
if (baubles.getStackInSlot(i) != itemStack) {
|
||||
continue;
|
||||
}
|
||||
|
||||
baubles.setInventorySlotContents(i, null);
|
||||
return;
|
||||
}
|
||||
// It shouldn't ever get to this point, because for the item to work at all, it needs to be in a bauble slot,
|
||||
// therefore I don't handle that edge case
|
||||
}
|
||||
}
|
||||
@@ -131,18 +131,6 @@ public class ItemInfusedSeeds extends ItemSeeds implements ITTinkererItem {
|
||||
icons[6] = IconHelper.forName(par1IconRegister, "seed_generic");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack stack, int renderPass) {
|
||||
Aspect aspect = getAspect(stack);
|
||||
if (aspect == null || aspect.isPrimal()) return 0xFFFFFF;
|
||||
return aspect.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
return getIconIndex(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconIndex(ItemStack stack) {
|
||||
return getAspect(stack) == null ? icons[0]
|
||||
|
||||
@@ -21,7 +21,7 @@ public final class LibMisc {
|
||||
|
||||
public static final String NETWORK_CHANNEL = MOD_ID;
|
||||
|
||||
public static final String DEPENDENCIES = "required-after:Forge@[10.12.1.1112,);required-after:Thaumcraft;before:advthaum;after:IC2;after:Waila;after:ForgeMultipart;after:ComputerCraft";
|
||||
public static final String DEPENDENCIES = "required-after:Forge@[10.12.1.1112,);required-after:Thaumcraft;before:advthaum;after:IC2;after:Waila;after:ForgeMultipart;after:ComputerCraft;after:dashboard@[1.0.11,)";
|
||||
|
||||
public static final String COMMON_PROXY = "thaumic.tinkerer.common.core.proxy.TTCommonProxy";
|
||||
public static final String CLIENT_PROXY = "thaumic.tinkerer.client.core.proxy.TTClientProxy";
|
||||
|
||||
@@ -6,22 +6,20 @@
|
||||
package thaumic.tinkerer.common.multipart;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartConverter;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory2;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
||||
// This class is used by FMP to recreate a part during loading and to convert already existing non-mutlipart blocks into
|
||||
// multiparts.
|
||||
// this is copied from the version FMP uses for vanilla torches
|
||||
public class RegisterBlockPart implements IPartFactory2, IPartConverter {
|
||||
public class RegisterBlockPart implements IPartFactory, IPartConverter {
|
||||
|
||||
Block block = null;
|
||||
Class<? extends TMultiPart> part = null;
|
||||
@@ -43,22 +41,7 @@ public class RegisterBlockPart implements IPartFactory2, IPartConverter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart createPart(String name, NBTTagCompound nbt) {
|
||||
return newPart(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart createPart(String name, MCDataInput packet) {
|
||||
return newPart(name);
|
||||
}
|
||||
|
||||
// Matches the legacy IPartFactory adapter, which answered previews with the client part.
|
||||
@Override
|
||||
public TMultiPart createPartForClientPreview(String name, NBTTagCompound nbt) {
|
||||
return newPart(name);
|
||||
}
|
||||
|
||||
private TMultiPart newPart(String name) {
|
||||
public TMultiPart createPart(String name, boolean client) {
|
||||
if (name.equals(name)) try {
|
||||
return part.getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
@@ -72,7 +55,7 @@ public class RegisterBlockPart implements IPartFactory2, IPartConverter {
|
||||
public void init() {
|
||||
if (name.isEmpty() || block == null || part == null) return;
|
||||
MultiPartRegistry.registerConverter(this);
|
||||
MultiPartRegistry.registerPartFactory(this, name);
|
||||
MultiPartRegistry.registerParts(this, new String[] { name });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,44 +45,66 @@ public class GuiHandler implements IGuiHandler {
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
return switch (ID) {
|
||||
case LibGuiIDs.GUI_ID_TABLET -> new ContainerAnimationTablet((TileAnimationTablet) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_MOB_MAGNET -> new ContainerMobMagnet((TileMobMagnet) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_ENCHANTER -> new ContainerEnchanter((TileEnchanter) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_ASPECT_ANALYZER -> new ContainerAspectAnalyzer(
|
||||
(TileAspectAnalyzer) tile,
|
||||
player.inventory);
|
||||
case LibGuiIDs.GUI_ID_ICHOR_POUCH -> isDimensionAllowed(player)
|
||||
? new ContainerIchorPouch(player, player.getCurrentEquippedItem())
|
||||
: null;
|
||||
case LibGuiIDs.GUI_ID_WARP_GATE -> new ContainerWarpGate((TileWarpGate) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_REMOTE_PLACER -> new ContainerRemotePlacer((TileRPlacer) tile, player.inventory);
|
||||
default -> null;
|
||||
};
|
||||
switch (ID) {
|
||||
case LibGuiIDs.GUI_ID_TABLET:
|
||||
return new ContainerAnimationTablet((TileAnimationTablet) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_MOB_MAGNET:
|
||||
return new ContainerMobMagnet((TileMobMagnet) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_ENCHANTER:
|
||||
return new ContainerEnchanter((TileEnchanter) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_ASPECT_ANALYZER:
|
||||
return new ContainerAspectAnalyzer((TileAspectAnalyzer) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_ICHOR_POUCH:
|
||||
if (!isDimensionAllowed(player)) return null;
|
||||
return new ContainerIchorPouch(player, player.getCurrentEquippedItem());
|
||||
|
||||
case LibGuiIDs.GUI_ID_WARP_GATE:
|
||||
return new ContainerWarpGate((TileWarpGate) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_REMOTE_PLACER:
|
||||
return new ContainerRemotePlacer((TileRPlacer) tile, player.inventory);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
return switch (ID) {
|
||||
case LibGuiIDs.GUI_ID_TABLET -> new GuiAnimationTablet((TileAnimationTablet) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_MOB_MAGNET -> new GuiMobMagnet((TileMobMagnet) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_ENCHANTER -> new GuiEnchanting((TileEnchanter) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_ASPECT_ANALYZER -> new GuiAspectAnalyzer((TileAspectAnalyzer) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_ICHOR_POUCH -> isDimensionAllowed(player)
|
||||
? new GuiIchorPouch(new ContainerIchorPouch(player, player.getCurrentEquippedItem()))
|
||||
: null;
|
||||
case LibGuiIDs.GUI_ID_WARP_GATE -> new GuiWarpGate((TileWarpGate) tile, player.inventory);
|
||||
case LibGuiIDs.GUI_ID_WARP_GATE_DESTINATIONS -> new GuiWarpGateDestinations((TileWarpGate) tile);
|
||||
case LibGuiIDs.GUI_ID_REMOTE_PLACER -> new GuiRemotePlacer((TileRPlacer) tile, player.inventory);
|
||||
default -> null;
|
||||
};
|
||||
switch (ID) {
|
||||
case LibGuiIDs.GUI_ID_TABLET:
|
||||
return new GuiAnimationTablet((TileAnimationTablet) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_MOB_MAGNET:
|
||||
return new GuiMobMagnet((TileMobMagnet) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_ENCHANTER:
|
||||
return new GuiEnchanting((TileEnchanter) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_ASPECT_ANALYZER:
|
||||
return new GuiAspectAnalyzer((TileAspectAnalyzer) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_ICHOR_POUCH:
|
||||
if ((!isDimensionAllowed(player))) return null;
|
||||
return new GuiIchorPouch(new ContainerIchorPouch(player, player.getCurrentEquippedItem()));
|
||||
|
||||
case LibGuiIDs.GUI_ID_WARP_GATE:
|
||||
return new GuiWarpGate((TileWarpGate) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_WARP_GATE_DESTINATIONS:
|
||||
return new GuiWarpGateDestinations((TileWarpGate) tile);
|
||||
case LibGuiIDs.GUI_ID_REMOTE_PLACER:
|
||||
return new GuiRemotePlacer((TileRPlacer) tile, player.inventory);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isDimensionAllowed(EntityPlayer player) {
|
||||
String currentDimID = Integer.toString(player.worldObj.provider.dimensionId);
|
||||
Integer currentDimID = (player.worldObj.provider.dimensionId);
|
||||
for (String id : ConfigHandler.forbiddenDimensions) {
|
||||
if (id.equals(currentDimID)) return false;
|
||||
if (id.equals(currentDimID.toString())) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+32
-24
@@ -12,74 +12,82 @@
|
||||
package thaumic.tinkerer.common.network.packet;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerEnchanter;
|
||||
import thaumic.tinkerer.common.block.tile.TileEnchanter;
|
||||
import thaumic.tinkerer.common.enchantment.core.EnchantmentManager;
|
||||
|
||||
public class PacketEnchanterAddEnchant implements IMessage, IMessageHandler<PacketEnchanterAddEnchant, IMessage> {
|
||||
public class PacketEnchanterAddEnchant extends PacketTile<TileEnchanter>
|
||||
implements IMessageHandler<PacketEnchanterAddEnchant, IMessage> {
|
||||
|
||||
private static final long serialVersionUID = -2182522429849764376L;
|
||||
int enchant;
|
||||
int level;
|
||||
|
||||
public PacketEnchanterAddEnchant() {}
|
||||
public PacketEnchanterAddEnchant() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PacketEnchanterAddEnchant(int enchant, int level) {
|
||||
public PacketEnchanterAddEnchant(TileEnchanter tile, int enchant, int level) {
|
||||
super(tile);
|
||||
this.enchant = enchant;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
super.toBytes(byteBuf);
|
||||
byteBuf.writeInt(enchant);
|
||||
byteBuf.writeInt(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
super.fromBytes(byteBuf);
|
||||
enchant = byteBuf.readInt();
|
||||
level = byteBuf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketEnchanterAddEnchant message, MessageContext ctx) {
|
||||
final var player = ctx.getServerHandler().playerEntity;
|
||||
if (!(player.openContainer instanceof ContainerEnchanter container)) return null;
|
||||
final var tile = container.enchanter;
|
||||
|
||||
if (tile.working) return null;
|
||||
super.onMessage(message, ctx);
|
||||
if (!ctx.side.isServer())
|
||||
throw new IllegalStateException("received PacketEnchanterAddEnchant " + message + "on client side!");
|
||||
if (message.tile.working) return null;
|
||||
|
||||
if (message.level == -1) {
|
||||
int index = tile.enchantments.indexOf(message.enchant);
|
||||
int index = message.tile.enchantments.indexOf(message.enchant);
|
||||
if (index != -1) {
|
||||
tile.removeLevel(index);
|
||||
tile.removeEnchant(index);
|
||||
message.tile.removeLevel(index);
|
||||
message.tile.removeEnchant(index);
|
||||
}
|
||||
} else {
|
||||
if (!tile.enchantments.contains(message.enchant)) {
|
||||
if (EnchantmentManager.canApply(
|
||||
tile.getStackInSlot(0),
|
||||
Enchantment.enchantmentsList[message.enchant],
|
||||
tile.enchantments)
|
||||
if (!message.tile.enchantments.contains(message.enchant)) {
|
||||
if (message.player != null
|
||||
&& EnchantmentManager.canApply(
|
||||
message.tile.getStackInSlot(0),
|
||||
Enchantment.enchantmentsList[message.enchant],
|
||||
message.tile.enchantments)
|
||||
&& EnchantmentManager.canEnchantmentBeUsed(
|
||||
player.getGameProfile().getName(),
|
||||
((EntityPlayer) message.player).getGameProfile().getName(),
|
||||
Enchantment.enchantmentsList[message.enchant])) {
|
||||
tile.appendEnchant(message.enchant);
|
||||
tile.appendLevel(1);
|
||||
message.tile.appendEnchant(message.enchant);
|
||||
message.tile.appendLevel(1);
|
||||
}
|
||||
} else {
|
||||
int maxLevel = Enchantment.enchantmentsList[message.enchant].getMaxLevel();
|
||||
tile.setLevel(
|
||||
tile.enchantments.indexOf(message.enchant),
|
||||
message.tile.setLevel(
|
||||
message.tile.enchantments.indexOf(message.enchant),
|
||||
Math.max(1, Math.min(maxLevel, message.level)));
|
||||
}
|
||||
}
|
||||
tile.updateAspectList();
|
||||
message.tile.updateAspectList();
|
||||
|
||||
tile.getWorldObj().markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
message.tile.getWorldObj().markBlockForUpdate(message.tile.xCoord, message.tile.yCoord, message.tile.zCoord);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+19
-16
@@ -14,29 +14,32 @@ package thaumic.tinkerer.common.network.packet;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerEnchanter;
|
||||
import thaumic.tinkerer.common.block.tile.TileEnchanter;
|
||||
|
||||
public class PacketEnchanterStartWorking implements IMessage, IMessageHandler<PacketEnchanterStartWorking, IMessage> {
|
||||
public class PacketEnchanterStartWorking extends PacketTile<TileEnchanter>
|
||||
implements IMessageHandler<PacketEnchanterStartWorking, IMessage> {
|
||||
|
||||
public PacketEnchanterStartWorking() {}
|
||||
private static final long serialVersionUID = -9086252088394185376L;
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {}
|
||||
public PacketEnchanterStartWorking() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {}
|
||||
public PacketEnchanterStartWorking(TileEnchanter tile) {
|
||||
super(tile);
|
||||
}
|
||||
|
||||
public void handle() {}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketEnchanterStartWorking message, MessageContext ctx) {
|
||||
final var player = ctx.getServerHandler().playerEntity;
|
||||
if (!(player.openContainer instanceof ContainerEnchanter container)) return null;
|
||||
final var tile = container.enchanter;
|
||||
|
||||
if (!tile.working && !tile.enchantments.isEmpty() && !tile.levels.isEmpty()) {
|
||||
tile.working = true;
|
||||
tile.markDirty();
|
||||
tile.getWorldObj().markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
super.onMessage(message, ctx);
|
||||
if (!ctx.side.isServer())
|
||||
throw new IllegalStateException("received PacketEnchanterStartWorking " + message + "on client side!");
|
||||
if (!message.tile.working && !message.tile.enchantments.isEmpty() && !message.tile.levels.isEmpty()) {
|
||||
message.tile.working = true;
|
||||
message.tile.getWorldObj()
|
||||
.markBlockForUpdate(message.tile.xCoord, message.tile.yCoord, message.tile.zCoord);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -16,34 +16,41 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import thaumic.tinkerer.common.block.tile.TileMobMagnet;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerMobMagnet;
|
||||
|
||||
public class PacketMobMagnetButton implements IMessage, IMessageHandler<PacketMobMagnetButton, IMessage> {
|
||||
public class PacketMobMagnetButton extends PacketTile<TileMobMagnet>
|
||||
implements IMessageHandler<PacketMobMagnetButton, IMessage> {
|
||||
|
||||
private static final long serialVersionUID = 7613980953987386713L;
|
||||
public boolean adult;
|
||||
|
||||
public PacketMobMagnetButton() {}
|
||||
public PacketMobMagnetButton() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PacketMobMagnetButton(TileMobMagnet tile) {
|
||||
super(tile);
|
||||
|
||||
adult = tile.adult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
super.toBytes(byteBuf);
|
||||
byteBuf.writeBoolean(adult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
super.fromBytes(byteBuf);
|
||||
adult = byteBuf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketMobMagnetButton message, MessageContext ctx) {
|
||||
final var player = ctx.getServerHandler().playerEntity;
|
||||
if (player.openContainer instanceof ContainerMobMagnet container) {
|
||||
container.mobMagnet.setAdult(adult);
|
||||
}
|
||||
super.onMessage(message, ctx);
|
||||
if (!ctx.side.isServer())
|
||||
throw new IllegalStateException("received PacketTabletbutton " + message + "on client side!");
|
||||
message.tile.adult = message.adult;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -5,38 +5,42 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import thaumic.tinkerer.common.block.tile.TileRPlacer;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerRemotePlacer;
|
||||
|
||||
/**
|
||||
* Created by nekosune on 30/06/14.
|
||||
*/
|
||||
public class PacketPlacerButton implements IMessage, IMessageHandler<PacketPlacerButton, IMessage> {
|
||||
public class PacketPlacerButton extends PacketTile<TileRPlacer>
|
||||
implements IMessageHandler<PacketPlacerButton, IMessage> {
|
||||
|
||||
public int blocks;
|
||||
|
||||
public PacketPlacerButton() {}
|
||||
public PacketPlacerButton() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PacketPlacerButton(TileRPlacer tile) {
|
||||
super(tile);
|
||||
blocks = tile.blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
super.toBytes(byteBuf);
|
||||
byteBuf.writeInt(blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
super.fromBytes(byteBuf);
|
||||
blocks = byteBuf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketPlacerButton message, MessageContext ctx) {
|
||||
final var player = ctx.getServerHandler().playerEntity;
|
||||
if (!(player.openContainer instanceof ContainerRemotePlacer container)) return null;
|
||||
final var tile = container.placer;
|
||||
|
||||
tile.setDistance(blocks);
|
||||
super.onMessage(message, ctx);
|
||||
if (!ctx.side.isServer())
|
||||
throw new IllegalStateException("received PacketPlacerbutton " + message + "on client side!");
|
||||
message.tile.blocks = message.blocks;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -15,43 +15,45 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerAnimationTablet;
|
||||
import thaumic.tinkerer.common.block.tile.tablet.TileAnimationTablet;
|
||||
|
||||
public class PacketTabletButton implements IMessage, IMessageHandler<PacketTabletButton, IMessage> {
|
||||
public class PacketTabletButton extends PacketTile<TileAnimationTablet>
|
||||
implements IMessageHandler<PacketTabletButton, IMessage> {
|
||||
|
||||
private static final long serialVersionUID = -6507755382924554527L;
|
||||
boolean leftClick, redstone;
|
||||
|
||||
public PacketTabletButton() {}
|
||||
public PacketTabletButton() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PacketTabletButton(TileAnimationTablet tile) {
|
||||
super(tile);
|
||||
leftClick = tile.leftClick;
|
||||
redstone = tile.redstone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
super.toBytes(byteBuf);
|
||||
byteBuf.writeBoolean(leftClick);
|
||||
byteBuf.writeBoolean(redstone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
super.fromBytes(byteBuf);
|
||||
leftClick = byteBuf.readBoolean();
|
||||
redstone = byteBuf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketTabletButton message, MessageContext ctx) {
|
||||
final var player = ctx.getServerHandler().playerEntity;
|
||||
if (!(player.openContainer instanceof ContainerAnimationTablet container)) return null;
|
||||
final var tile = container.tablet;
|
||||
|
||||
tile.leftClick = message.leftClick;
|
||||
tile.redstone = message.redstone;
|
||||
tile.markDirty();
|
||||
tile.getWorldObj().markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
|
||||
super.onMessage(message, ctx);
|
||||
if (!ctx.side.isServer())
|
||||
throw new IllegalStateException("received PacketTabletbutton " + message + "on client side!");
|
||||
message.tile.leftClick = message.leftClick;
|
||||
message.tile.redstone = message.redstone;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as part of the ThaumicTinkerer Mod.
|
||||
*
|
||||
* ThaumicTinkerer is Open Source and distributed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0
|
||||
* License (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* ThaumicTinkerer is a Derivative Work on Thaumcraft 4. Thaumcraft 4 (c) Azanor 2012
|
||||
* (http://www.minecraftforum.net/topic/1585216-)
|
||||
*
|
||||
* File Created @ [9 Sep 2013, 17:00:10 (GMT)]
|
||||
*/
|
||||
package thaumic.tinkerer.common.network.packet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import thaumic.tinkerer.client.core.proxy.TTClientProxy;
|
||||
import thaumic.tinkerer.common.core.helper.MiscHelper;
|
||||
|
||||
public abstract class PacketTile<T extends TileEntity> implements IMessage {
|
||||
|
||||
private static final long serialVersionUID = -1447633008013055477L;
|
||||
protected int dim, x, y, z;
|
||||
protected transient T tile;
|
||||
protected transient EntityPlayer player;
|
||||
|
||||
public PacketTile() {}
|
||||
|
||||
public PacketTile(T tile) {
|
||||
this.tile = tile;
|
||||
|
||||
this.x = tile.xCoord;
|
||||
this.y = tile.yCoord;
|
||||
this.z = tile.zCoord;
|
||||
this.dim = tile.getWorldObj().provider.dimensionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
byteBuf.writeInt(x);
|
||||
byteBuf.writeInt(y);
|
||||
byteBuf.writeInt(z);
|
||||
byteBuf.writeInt(dim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
x = byteBuf.readInt();
|
||||
y = byteBuf.readInt();
|
||||
z = byteBuf.readInt();
|
||||
dim = byteBuf.readInt();
|
||||
}
|
||||
|
||||
public IMessage onMessage(PacketTile message, MessageContext ctx) {
|
||||
MinecraftServer server = MiscHelper.server();
|
||||
if (ctx.side.isClient()) message.player = TTClientProxy.getPlayer();
|
||||
else {
|
||||
message.player = ctx.getServerHandler().playerEntity;
|
||||
}
|
||||
if (server != null) {
|
||||
World world = server.worldServerForDimension(message.dim);
|
||||
|
||||
if (world == null) {
|
||||
MiscHelper.printCurrentStackTrace("No world found for dimension " + message.dim + "!");
|
||||
return null;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(message.x, message.y, message.z);
|
||||
if (tile != null) {
|
||||
message.tile = (T) tile;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+14
-7
@@ -15,35 +15,42 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import thaumic.tinkerer.common.block.tile.container.kami.ContainerWarpGate;
|
||||
import thaumic.tinkerer.common.block.tile.kami.TileWarpGate;
|
||||
import thaumic.tinkerer.common.network.packet.PacketTile;
|
||||
|
||||
public class PacketWarpGateButton implements IMessage, IMessageHandler<PacketWarpGateButton, IMessage> {
|
||||
public class PacketWarpGateButton extends PacketTile<TileWarpGate>
|
||||
implements IMessageHandler<PacketWarpGateButton, IMessage> {
|
||||
|
||||
private static final long serialVersionUID = 1497188581985763661L;
|
||||
boolean locked;
|
||||
|
||||
public PacketWarpGateButton() {}
|
||||
public PacketWarpGateButton() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PacketWarpGateButton(TileWarpGate tile) {
|
||||
super(tile);
|
||||
locked = tile.locked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
super.toBytes(byteBuf);
|
||||
byteBuf.writeBoolean(locked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
super.fromBytes(byteBuf);
|
||||
locked = byteBuf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketWarpGateButton message, MessageContext ctx) {
|
||||
final var player = ctx.getServerHandler().playerEntity;
|
||||
if (player.openContainer instanceof ContainerWarpGate container) {
|
||||
container.gate.setLocked(locked);
|
||||
}
|
||||
super.onMessage(message, ctx);
|
||||
if (!ctx.side.isServer())
|
||||
throw new IllegalStateException("received PacketWarpgateButton " + message + "on client side!");
|
||||
message.tile.locked = message.locked;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+17
-21
@@ -11,53 +11,49 @@
|
||||
*/
|
||||
package thaumic.tinkerer.common.network.packet.kami;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import thaumic.tinkerer.common.block.tile.kami.TileWarpGate;
|
||||
import thaumic.tinkerer.common.network.packet.PacketTile;
|
||||
|
||||
public class PacketWarpGateTeleport implements IMessage, IMessageHandler<PacketWarpGateTeleport, IMessage> {
|
||||
public class PacketWarpGateTeleport extends PacketTile<TileWarpGate>
|
||||
implements IMessageHandler<PacketWarpGateTeleport, IMessage> {
|
||||
|
||||
int x, y, z;
|
||||
private static final long serialVersionUID = 2247241734524685744L;
|
||||
int index;
|
||||
|
||||
public PacketWarpGateTeleport() {}
|
||||
public PacketWarpGateTeleport() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PacketWarpGateTeleport(TileWarpGate tile, int index) {
|
||||
this.x = tile.xCoord;
|
||||
this.y = tile.yCoord;
|
||||
this.z = tile.zCoord;
|
||||
super(tile);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
byteBuf.writeInt(x);
|
||||
byteBuf.writeInt(y);
|
||||
byteBuf.writeInt(z);
|
||||
super.toBytes(byteBuf);
|
||||
byteBuf.writeInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
x = byteBuf.readInt();
|
||||
y = byteBuf.readInt();
|
||||
z = byteBuf.readInt();
|
||||
super.fromBytes(byteBuf);
|
||||
index = byteBuf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketWarpGateTeleport message, MessageContext ctx) {
|
||||
final var player = ctx.getServerHandler().playerEntity;
|
||||
final var world = player.worldObj;
|
||||
|
||||
if (world.blockExists(message.x, message.y, message.z)
|
||||
&& world.getTileEntity(message.x, message.y, message.z) instanceof TileWarpGate warpGate
|
||||
&& player.boundingBox.intersectsWith(warpGate.getTeleportRange().expand(0.1, 0.1, 0.1))) {
|
||||
warpGate.teleportPlayer(player, message.index);
|
||||
}
|
||||
|
||||
super.onMessage(message, ctx);
|
||||
if (!ctx.side.isServer())
|
||||
throw new IllegalStateException("received PacketTabletbutton " + message + "on client side!");
|
||||
if (message.player instanceof EntityPlayer)
|
||||
message.tile.teleportPlayer((EntityPlayer) message.player, message.index);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -194,15 +194,13 @@ public class TTRegistry {
|
||||
blockRegistry.put(newBlock.getClass(), blockList);
|
||||
blockList[0] = newBlock;
|
||||
|
||||
// Fill list before registering, ItemBlock constructors read it
|
||||
int index = 1;
|
||||
for (Block metaBlock : metaBlocks) {
|
||||
metaBlock.setBlockName(((ITTinkererBlock) metaBlock).getBlockName());
|
||||
blockList[index++] = metaBlock;
|
||||
}
|
||||
registerBlock(newBlock, ittBlock);
|
||||
for (Block metaBlock : metaBlocks) {
|
||||
registerBlock(metaBlock, (ITTinkererBlock) metaBlock);
|
||||
ITTinkererBlock metaIttBlock = (ITTinkererBlock) metaBlock;
|
||||
metaBlock.setBlockName(metaIttBlock.getBlockName());
|
||||
blockList[index++] = metaBlock;
|
||||
registerBlock(metaBlock, metaIttBlock);
|
||||
}
|
||||
|
||||
Class<? extends ItemBlock> itemBlock = ittBlock.getItemBlock();
|
||||
|
||||
Reference in new issue
Block a user