mirror of
https://github.com/GTNewHorizons/ThaumicTinkerer.git
synced 2026-11-28 16:06:07 +00:00
Compare commits
41
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5268737e2e | ||
|
|
c075644243 | ||
|
|
e95d6c870c | ||
|
|
6d278db79d | ||
|
|
4f2618d03b | ||
|
|
c2cbc66645 | ||
|
|
df4a8cfca9 | ||
|
|
00e831c20f | ||
|
|
7fbffb3aa7 | ||
|
|
7b02309128 | ||
|
|
c9be818502 | ||
|
|
3e96d49fef | ||
|
|
64d179543c | ||
|
|
e1d8a847a9 | ||
|
|
38fb7fc71f | ||
|
|
6479b0b635 | ||
|
|
5b388b5cba | ||
|
|
3cc1026704 | ||
|
|
2a548be7d8 | ||
|
|
dce00bbc74 | ||
|
|
63bf13c964 | ||
|
|
2151886e83 | ||
|
|
aeb6392d52 | ||
|
|
c221b7b03b | ||
|
|
bf664d00c8 | ||
|
|
7f7c4083cc | ||
|
|
d3f9b102d6 | ||
|
|
0f74be83ac | ||
|
|
a61d4b6d9f | ||
|
|
e4d716addb | ||
|
|
393eec213c | ||
|
|
40ce1b4c61 | ||
|
|
292be28f00 | ||
|
|
3809971825 | ||
|
|
db796ae830 | ||
|
|
d92266f5e3 | ||
|
|
304fed71dd | ||
|
|
bd2506a479 | ||
|
|
62a9677326 | ||
|
|
b259785bbc | ||
|
|
d4191557af |
No files matched your search
@@ -30,3 +30,4 @@ src/main/resources/mixins.*([!.]).json
|
||||
*.bat
|
||||
*.DS_Store
|
||||
!gradlew.bat
|
||||
layout.json
|
||||
+22
-16
@@ -1,23 +1,29 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:Baubles:1.0.4:dev')
|
||||
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-402-GTNH:api')
|
||||
|
||||
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-688-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.11.1-GTNH:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:EnderCore:0.4.6:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:EnderIO:2.8.0:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:EnderStorage:1.6.0:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:waila:1.8.0:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:TinkersConstruct:1.12.1-GTNH:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.4.8:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:CodeChickenLib:1.2.1:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:OpenComputers:1.10.11-GTNH:api') {transitive=false}
|
||||
|
||||
compileOnly('curse.maven:computercraft-67504:2269339')
|
||||
compileOnly('curse.maven:cofh-lib-220333:2388748')
|
||||
compileOnly('curse.maven:cofh-core-69162:2388751')
|
||||
compileOnly('com.github.GTNewHorizons:Botania:1.12.25-GTNH:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:EnderCore:0.4.8:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:EnderIO:2.9.22:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:EnderStorage:1.7.7:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:waila:1.8.14:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:TinkersConstruct:1.13.54-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.459: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.4:dev') {
|
||||
exclude module: 'Baubles'
|
||||
}
|
||||
}
|
||||
+15
-4
@@ -14,7 +14,7 @@ modId = ThaumicTinkerer
|
||||
modGroup = thaumic.tinkerer
|
||||
|
||||
# Whether to use modGroup as the maven publishing group.
|
||||
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
|
||||
# When false, com.github.GTNewHorizons is used.
|
||||
useModGroupForPublishing = false
|
||||
|
||||
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
||||
@@ -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.
|
||||
@@ -85,6 +85,11 @@ accessTransformersFile = ThaumicTinkerer_at.cfg
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = true
|
||||
|
||||
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
|
||||
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
|
||||
# Mixin classes will have access to "main" classes, but not the other way around.
|
||||
separateMixinSourceSet =
|
||||
|
||||
# Adds some debug arguments like verbose output and class export.
|
||||
usesMixinDebug = true
|
||||
|
||||
@@ -117,9 +122,15 @@ minimizeShadowedDependencies = true
|
||||
# If disabled, won't rename the shadowed classes.
|
||||
relocateShadowedDependencies = true
|
||||
|
||||
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
|
||||
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
|
||||
includeWellKnownRepositories = true
|
||||
|
||||
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
|
||||
# list of strings, with the acceptable keys being(case does not matter):
|
||||
# cursemaven
|
||||
# modrinth
|
||||
excludeWellKnownRepositories =
|
||||
|
||||
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
|
||||
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
|
||||
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
|
||||
@@ -140,7 +151,7 @@ modrinthProjectId =
|
||||
# type can be one of [project, version],
|
||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
||||
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
|
||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||
modrinthRelations =
|
||||
|
||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -203,7 +205,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
Vendored
+2
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
|
||||
@@ -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
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.23'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.43'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package thaumic.tinkerer.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
|
||||
public class VisweaverRecipe {
|
||||
|
||||
private final int centivisCost;
|
||||
private final Aspect centivisType;
|
||||
private final ItemStack input;
|
||||
private final ItemStack output;
|
||||
|
||||
VisweaverRecipe(int centivisCost, Aspect centivisType, ItemStack input, ItemStack output) {
|
||||
this.centivisCost = centivisCost;
|
||||
this.centivisType = centivisType;
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public int getCentivisCost() {
|
||||
return centivisCost;
|
||||
}
|
||||
|
||||
public Aspect getCentivisType() {
|
||||
return centivisType;
|
||||
}
|
||||
|
||||
public ItemStack getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package thaumic.tinkerer.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumic.tinkerer.common.core.helper.ItemHashStrategy;
|
||||
|
||||
public class VisweaverRecipeMap {
|
||||
|
||||
/*
|
||||
* Hashmap using a hashing strategy suited to comparing items
|
||||
*/
|
||||
private static final Object2ObjectOpenCustomHashMap<ItemStack, VisweaverRecipe> recipeMap = new Object2ObjectOpenCustomHashMap<>(
|
||||
new ItemHashStrategy());
|
||||
|
||||
private VisweaverRecipeMap() {}
|
||||
|
||||
public static VisweaverRecipe lookup(ItemStack input) {
|
||||
return recipeMap.get(input);
|
||||
}
|
||||
|
||||
public static void putRecipe(int centivisCost, Aspect centivisType, ItemStack input, ItemStack output) {
|
||||
VisweaverRecipe recipe = new VisweaverRecipe(centivisCost, centivisType, input, output);
|
||||
recipeMap.put(input, recipe);
|
||||
}
|
||||
}
|
||||
+19
-29
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ import thaumic.tinkerer.client.lib.LibRenderIDs;
|
||||
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.RenderVisweaver;
|
||||
import thaumic.tinkerer.client.render.block.kami.RenderWarpGate;
|
||||
import thaumic.tinkerer.client.render.item.RenderGenericSeeds;
|
||||
import thaumic.tinkerer.client.render.item.RenderMobDisplay;
|
||||
@@ -50,14 +49,12 @@ import thaumic.tinkerer.client.render.tile.RenderTileEnchanter;
|
||||
import thaumic.tinkerer.client.render.tile.RenderTileFunnel;
|
||||
import thaumic.tinkerer.client.render.tile.RenderTileMagnet;
|
||||
import thaumic.tinkerer.client.render.tile.RenderTileRepairer;
|
||||
import thaumic.tinkerer.client.render.tile.RenderTileVisweaver;
|
||||
import thaumic.tinkerer.client.render.tile.kami.RenderTileWarpGate;
|
||||
import thaumic.tinkerer.common.ThaumicTinkerer;
|
||||
import thaumic.tinkerer.common.block.tile.TileEnchanter;
|
||||
import thaumic.tinkerer.common.block.tile.TileFunnel;
|
||||
import thaumic.tinkerer.common.block.tile.TileMagnet;
|
||||
import thaumic.tinkerer.common.block.tile.TileRepairer;
|
||||
import thaumic.tinkerer.common.block.tile.TileVisweaver;
|
||||
import thaumic.tinkerer.common.block.tile.kami.TileWarpGate;
|
||||
import thaumic.tinkerer.common.block.tile.tablet.TileAnimationTablet;
|
||||
import thaumic.tinkerer.common.compat.FumeTool;
|
||||
@@ -117,7 +114,6 @@ public class TTClientProxy extends TTCommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, new RenderTileEnchanter());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileFunnel.class, new RenderTileFunnel());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileRepairer.class, new RenderTileRepairer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileVisweaver.class, new RenderTileVisweaver());
|
||||
|
||||
LibRenderIDs.idGrain = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(LibRenderIDs.idGrain, new RenderInfusedCrops());
|
||||
@@ -131,10 +127,8 @@ public class TTClientProxy extends TTCommonProxy {
|
||||
LibRenderIDs.idMagnet = RenderingRegistry.getNextAvailableRenderId();
|
||||
LibRenderIDs.idRepairer = RenderingRegistry.getNextAvailableRenderId();
|
||||
LibRenderIDs.idFire = RenderingRegistry.getNextAvailableRenderId();
|
||||
LibRenderIDs.idVisweaver = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(new RenderMagnet());
|
||||
RenderingRegistry.registerBlockHandler(new RenderRepairer());
|
||||
RenderingRegistry.registerBlockHandler(new RenderVisweaver());
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ThaumicTinkerer.registry.getFirstItemFromClass(ItemMobDisplay.class),
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
package thaumic.tinkerer.client.gui;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import thaumic.tinkerer.client.core.helper.ClientHelper;
|
||||
import thaumic.tinkerer.client.lib.LibResources;
|
||||
import thaumic.tinkerer.common.block.tile.TileVisweaver;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerVisweaver;
|
||||
|
||||
public class GUIVisweaver extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation gui = new ResourceLocation(LibResources.GUI_VISWEAVER);
|
||||
public TileVisweaver visweaver;
|
||||
public List<String> tooltip = new ArrayList<>();
|
||||
int x, y;
|
||||
ItemStack lastTickStack;
|
||||
ItemStack currentStack;
|
||||
|
||||
public GUIVisweaver(TileVisweaver visweaver, InventoryPlayer inv) {
|
||||
super(new ContainerVisweaver(visweaver, inv));
|
||||
this.visweaver = visweaver;
|
||||
lastTickStack = visweaver.getStackInSlot(0);
|
||||
currentStack = visweaver.getStackInSlot(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
x = (width - xSize) / 2;
|
||||
y = (height - ySize) / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
currentStack = visweaver.getStackInSlot(0);
|
||||
lastTickStack = currentStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
mc.renderEngine.bindTexture(gui);
|
||||
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
if (visweaver.isWorking()) {
|
||||
int pixels = (int) (67D * ((double) visweaver.getInternalVis() / (double) visweaver.getRequiredVis()));
|
||||
|
||||
// Draw aspect color to fill
|
||||
Color color = new Color(visweaver.getCvType().getColor());
|
||||
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
|
||||
drawTexturedModalRect(x + 56, y + 35, 185, 10, pixels, 8);
|
||||
}
|
||||
|
||||
// Draw aspect "container" over progressbar
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
drawTexturedModalRect(x + 49, y + 34, 178, 0, 78, 10);
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
if (!tooltip.isEmpty()) ClientHelper.renderTooltip(par1 - x, par2 - y, tooltip);
|
||||
tooltip.clear();
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,8 @@ public class GuiButtonWG extends GuiButton {
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
|
||||
if (enabled) {
|
||||
par1Minecraft.renderEngine.bindTexture(gui);
|
||||
int y = !enabled ? 13 : 0;
|
||||
drawTexturedModalRect(xPosition, yPosition, 176, y, width, height);
|
||||
}
|
||||
par1Minecraft.renderEngine.bindTexture(gui);
|
||||
int y = !enabled ? 13 : 0;
|
||||
drawTexturedModalRect(xPosition, yPosition, 176, y, width, height);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ public final class LibRenderIDs {
|
||||
|
||||
public static int idMagnet = -1;
|
||||
public static int idRepairer = -1;
|
||||
public static int idVisweaver = -1;
|
||||
|
||||
public static int idWarpGate = -1;
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ public final class LibResources {
|
||||
public static final String GUI_ICHOR_POUCH = PREFIX_GUI + "ichorPouch.png";
|
||||
public static final String GUI_WARP_GATE = PREFIX_GUI + "warpGate.png";
|
||||
public static final String GUI_REMOTE_PLACER = PREFIX_GUI + "remotePlacer.png";
|
||||
public static final String GUI_VISWEAVER = PREFIX_GUI + "visweaver.png";
|
||||
|
||||
public static final String MISC_R_ENCHANTING = PREFIX_MISC + "r_enchanting.png";
|
||||
public static final String MISC_AT_CENTER = PREFIX_MISC + "atCenter.png";
|
||||
@@ -55,7 +54,6 @@ public final class LibResources {
|
||||
public static final String MODEL_ARMOR_ICHOR_2 = PREFIX_MODEL + "ichor2.png";
|
||||
public static final String MODEL_ARMOR_ICHOR_GEM_1 = PREFIX_MODEL + "ichorGem1.png";
|
||||
public static final String MODEL_ARMOR_ICHOR_GEM_2 = PREFIX_MODEL + "ichorGem2.png";
|
||||
public static final String MODEL_VISWEAVER = PREFIX_MODEL + "visweaver.png";
|
||||
|
||||
public static final String ENCHANT_PROTECTION = PREFIX_ENCHANTS + "protection.png";
|
||||
public static final String ENCHANT_FIRE_PROTECTION = PREFIX_ENCHANTS + "fireProtection.png";
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
package thaumic.tinkerer.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
|
||||
public class ModelVisweaver extends ModelBase {
|
||||
|
||||
public ModelRenderer base;
|
||||
public ModelRenderer top;
|
||||
public ModelRenderer pillar1;
|
||||
public ModelRenderer pillar2;
|
||||
public ModelRenderer pillar3;
|
||||
public ModelRenderer pillar4;
|
||||
public ModelRenderer orbBase;
|
||||
|
||||
public ModelRenderer orbIgnis;
|
||||
public ModelRenderer orbAqua;
|
||||
public ModelRenderer orbAer;
|
||||
public ModelRenderer orbTerra;
|
||||
public ModelRenderer orbOrdo;
|
||||
public ModelRenderer orbPerditio;
|
||||
|
||||
public ModelRenderer orbCarrier;
|
||||
|
||||
public ModelVisweaver() {
|
||||
this.textureWidth = 64;
|
||||
this.textureHeight = 36;
|
||||
|
||||
this.pillar1 = new ModelRenderer(this, 0, 0);
|
||||
this.pillar1.setRotationPoint(-7.0F, 14.0F, 5.0F);
|
||||
this.pillar1.addBox(0.0F, 0.0F, 0.0F, 2, 8, 2, 0.0F);
|
||||
this.pillar2 = new ModelRenderer(this, 0, 0);
|
||||
this.pillar2.setRotationPoint(5.0F, 14.0F, 5.0F);
|
||||
this.pillar2.addBox(0.0F, 0.0F, 0.0F, 2, 8, 2, 0.0F);
|
||||
this.pillar3 = new ModelRenderer(this, 0, 0);
|
||||
this.pillar3.setRotationPoint(5.0F, 14.0F, -7.0F);
|
||||
this.pillar3.addBox(0.0F, 0.0F, 0.0F, 2, 8, 2, 0.0F);
|
||||
this.pillar4 = new ModelRenderer(this, 0, 0);
|
||||
this.pillar4.setRotationPoint(-7.0F, 14.0F, -7.0F);
|
||||
this.pillar4.addBox(0.0F, 0.0F, 0.0F, 2, 8, 2, 0.0F);
|
||||
|
||||
this.top = new ModelRenderer(this, 0, 0);
|
||||
this.top.setRotationPoint(-8.0F, 12.0F, -8.0F);
|
||||
this.top.addBox(0.0F, 0.0F, 0.0F, 16, 2, 16, 0.0F);
|
||||
|
||||
this.base = new ModelRenderer(this, 0, 18);
|
||||
this.base.setRotationPoint(-8.0F, 22.0F, -8.0F);
|
||||
this.base.addBox(0.0F, 0.0F, 0.0F, 16, 2, 16, 0.0F);
|
||||
|
||||
this.orbBase = new ModelRenderer(this, 48, 0);
|
||||
this.orbBase.setRotationPoint(0, 8, 0);
|
||||
this.orbBase.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
|
||||
|
||||
this.orbIgnis = new ModelRenderer(this, 56, 4);
|
||||
this.orbIgnis.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
|
||||
this.orbIgnis.setRotationPoint(0, 8, 0);
|
||||
this.orbAqua = new ModelRenderer(this, 56, 12);
|
||||
this.orbAqua.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
|
||||
this.orbAqua.setRotationPoint(0, 8, 0);
|
||||
this.orbAer = new ModelRenderer(this, 56, 8);
|
||||
this.orbAer.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
|
||||
this.orbAer.setRotationPoint(0, 8, 0);
|
||||
this.orbTerra = new ModelRenderer(this, 48, 8);
|
||||
this.orbTerra.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
|
||||
this.orbTerra.setRotationPoint(0, 8, 0);
|
||||
this.orbOrdo = new ModelRenderer(this, 48, 12);
|
||||
this.orbOrdo.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
|
||||
this.orbOrdo.setRotationPoint(0, 8, 0);
|
||||
this.orbPerditio = new ModelRenderer(this, 48, 4);
|
||||
this.orbPerditio.addBox(0.0F, 0.0F, 0.0F, 2, 2, 2, 0.0F);
|
||||
this.orbPerditio.setRotationPoint(0, 8, 0);
|
||||
|
||||
this.orbCarrier = new ModelRenderer(this);
|
||||
this.orbCarrier.addChild(this.orbBase);
|
||||
this.orbCarrier.addChild(this.orbIgnis);
|
||||
this.orbCarrier.addChild(this.orbAqua);
|
||||
this.orbCarrier.addChild(this.orbAer);
|
||||
this.orbCarrier.addChild(this.orbTerra);
|
||||
this.orbCarrier.addChild(this.orbOrdo);
|
||||
this.orbCarrier.addChild(this.orbPerditio);
|
||||
}
|
||||
|
||||
public void render(boolean isWorking, int tickCounter, Aspect cvType) {
|
||||
final float scale = 1F / 16F;
|
||||
|
||||
float xyRotate = (float) tickCounter / 20F;
|
||||
float zRotate = (float) tickCounter / 100F;
|
||||
|
||||
orbCarrier.rotationPointX = (float) Math.sin((float) tickCounter / 10.0F) * 2.0F;
|
||||
|
||||
float orbitRotation = ((float) tickCounter / 40F) % (2F * (float) Math.PI);
|
||||
setRotateAngle(orbCarrier, 0F, orbitRotation, 0F);
|
||||
|
||||
ModelRenderer toRender = getToRender(isWorking, cvType);
|
||||
setRotateAngle(toRender, xyRotate, xyRotate, zRotate);
|
||||
toRender.render(scale);
|
||||
|
||||
this.pillar3.render(scale);
|
||||
this.top.render(scale);
|
||||
this.pillar4.render(scale);
|
||||
this.base.render(scale);
|
||||
this.pillar1.render(scale);
|
||||
this.pillar2.render(scale);
|
||||
}
|
||||
|
||||
private ModelRenderer getToRender(boolean isWorking, Aspect cvType) {
|
||||
ModelRenderer toRender = orbBase;
|
||||
|
||||
if (isWorking) {
|
||||
if (cvType == Aspect.AIR) {
|
||||
toRender = orbAer;
|
||||
} else if (cvType == Aspect.FIRE) {
|
||||
toRender = orbIgnis;
|
||||
} else if (cvType == Aspect.ORDER) {
|
||||
toRender = orbOrdo;
|
||||
} else if (cvType == Aspect.ENTROPY) {
|
||||
toRender = orbPerditio;
|
||||
} else if (cvType == Aspect.WATER) {
|
||||
toRender = orbAqua;
|
||||
} else if (cvType == Aspect.EARTH) {
|
||||
toRender = orbTerra;
|
||||
}
|
||||
}
|
||||
return toRender;
|
||||
}
|
||||
|
||||
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
|
||||
modelRenderer.rotateAngleX = x;
|
||||
modelRenderer.rotateAngleY = y;
|
||||
modelRenderer.rotateAngleZ = z;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public class RenderInfusedCrops implements ISimpleBlockRenderingHandler {
|
||||
Aspect aspect = BlockInfusedGrain.getAspect(world, x, y, z);
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
if (aspect != null && !aspect.isPrimal()) {
|
||||
// Hex to RGB code from vanilla tesselator
|
||||
float r = (aspect.getColor() >> 16 & 0xFF) / 255.0F;
|
||||
@@ -34,15 +35,14 @@ public class RenderInfusedCrops implements ISimpleBlockRenderingHandler {
|
||||
float b = (aspect.getColor() & 0xFF) / 255.0F;
|
||||
|
||||
GL11.glColor4f(r, g, b, 1F);
|
||||
Tessellator.instance.setColorRGBA_I(aspect.getColor(), 255);
|
||||
tess.setColorRGBA_I(aspect.getColor(), 255);
|
||||
}
|
||||
|
||||
renderer.setOverrideBlockTexture(block.getIcon(world, x, y, z, world.getBlockMetadata(x, y, z)));
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tess.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
renderer.renderBlockCropsImpl(block, world.getBlockMetadata(x, y, z), x, y - 0.0625F, z);
|
||||
renderer.clearOverrideBlockTexture();
|
||||
// Tessellator.instance.setColorOpaque_I(0xFFFFFF);
|
||||
// tess.setColorOpaque_I(0xFFFFFF);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package thaumic.tinkerer.client.render.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import thaumic.tinkerer.client.lib.LibRenderIDs;
|
||||
import thaumic.tinkerer.common.block.tile.TileVisweaver;
|
||||
|
||||
public class RenderVisweaver implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileVisweaver(), 0.0D, 0.0D, 0.0D, 0.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
|
||||
RenderBlocks renderer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return LibRenderIDs.idVisweaver;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
package thaumic.tinkerer.client.render.tile;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -20,6 +22,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import thaumcraft.client.renderers.block.BlockJarRenderer;
|
||||
import thaumcraft.client.renderers.tile.ItemJarFilledRenderer;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumic.tinkerer.common.block.tile.TileFunnel;
|
||||
|
||||
public class RenderTileFunnel extends TileEntitySpecialRenderer {
|
||||
@@ -34,12 +37,12 @@ public class RenderTileFunnel extends TileEntitySpecialRenderer {
|
||||
if (stack != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(d0 + 0.5, d1 + 0.365, d2 + 0.5);
|
||||
// if(Block.getBlockFromItem(stack.getItem())== ConfigBlocks.blockJar) {
|
||||
// GL11.glTranslatef(0F, 0.25F, 0F);
|
||||
// jarRenderer.renderInventoryBlock(ConfigBlocks.blockJar, 0, 0, new RenderBlocks());
|
||||
// }
|
||||
// else
|
||||
jarRenderer1.renderItem(IItemRenderer.ItemRenderType.ENTITY, stack, (Object[]) null);
|
||||
if (Block.getBlockFromItem(stack.getItem()) == ConfigBlocks.blockJar) {
|
||||
GL11.glTranslatef(0F, 0.25F, 0F);
|
||||
jarRenderer.renderInventoryBlock(ConfigBlocks.blockJar, stack.getItemDamage(), 0, new RenderBlocks());
|
||||
} else {
|
||||
jarRenderer1.renderItem(IItemRenderer.ItemRenderType.ENTITY, stack, (Object[]) null);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package thaumic.tinkerer.client.render.tile;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import thaumic.tinkerer.client.core.helper.ClientHelper;
|
||||
import thaumic.tinkerer.client.lib.LibResources;
|
||||
import thaumic.tinkerer.client.model.ModelVisweaver;
|
||||
import thaumic.tinkerer.common.block.tile.TileVisweaver;
|
||||
|
||||
public class RenderTileVisweaver extends TileEntitySpecialRenderer {
|
||||
|
||||
private static final ResourceLocation modelTex = new ResourceLocation(LibResources.MODEL_VISWEAVER);
|
||||
ModelVisweaver model = new ModelVisweaver();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
|
||||
|
||||
TileVisweaver visweaver = (TileVisweaver) tileentity;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
|
||||
ClientHelper.minecraft().renderEngine.bindTexture(modelTex);
|
||||
|
||||
GL11.glTranslatef(0.5F, 1.5F, 0.5F);
|
||||
GL11.glScalef(1F, -1F, -1F);
|
||||
|
||||
model.render(visweaver.isWorking(), visweaver.getTickCounter(), visweaver.getCvType());
|
||||
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glTranslatef(0F, 0F, -0.6F);
|
||||
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,10 @@ public class ThaumicTinkerer {
|
||||
@SidedProxy(clientSide = LibMisc.CLIENT_PROXY, serverSide = LibMisc.COMMON_PROXY)
|
||||
public static TTCommonProxy proxy;
|
||||
|
||||
public static boolean isBootsActive = false;
|
||||
public static boolean gtLoaded;
|
||||
public static final String BOOTS = "thaumicboots";
|
||||
|
||||
public static CommonProxy tcProxy;
|
||||
public static SimpleNetworkWrapper netHandler = NetworkRegistry.INSTANCE.newSimpleChannel(LibMisc.MOD_ID + "|B");
|
||||
|
||||
@@ -74,6 +78,10 @@ public class ThaumicTinkerer {
|
||||
"register",
|
||||
"thaumic.tinkerer.common.compat.TTinkererProvider.callbackRegister");
|
||||
}
|
||||
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);
|
||||
@@ -162,18 +160,9 @@ public class BlockAnimationTablet extends BlockModContainer {
|
||||
@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());
|
||||
if (tile instanceof TileAnimationTablet tablet) {
|
||||
if (tablet.redstone && tablet.isIdle()) {
|
||||
tablet.initiateSwing();
|
||||
par1World.addBlockEvent(
|
||||
par2,
|
||||
par3,
|
||||
par4,
|
||||
ThaumicTinkerer.registry.getFirstBlockFromClass(BlockAnimationTablet.class),
|
||||
0,
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,13 +172,12 @@ public class BlockAnimationTablet extends BlockModContainer {
|
||||
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 +256,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 +266,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",
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
package thaumic.tinkerer.common.block;
|
||||
|
||||
import static thaumic.tinkerer.common.lib.LibBlockNames.VISWEAVER;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.research.ResearchPage;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumic.tinkerer.api.VisweaverRecipeMap;
|
||||
import thaumic.tinkerer.client.lib.LibRenderIDs;
|
||||
import thaumic.tinkerer.common.ThaumicTinkerer;
|
||||
import thaumic.tinkerer.common.block.tile.TileVisweaver;
|
||||
import thaumic.tinkerer.common.item.ItemSpellCloth;
|
||||
import thaumic.tinkerer.common.lib.LibGuiIDs;
|
||||
import thaumic.tinkerer.common.lib.LibResearch;
|
||||
import thaumic.tinkerer.common.registry.ThaumicTinkererInfusionRecipe;
|
||||
import thaumic.tinkerer.common.registry.ThaumicTinkererRecipe;
|
||||
import thaumic.tinkerer.common.research.IRegisterableResearch;
|
||||
import thaumic.tinkerer.common.research.ResearchHelper;
|
||||
import thaumic.tinkerer.common.research.TTResearchItem;
|
||||
|
||||
public class BlockVisweaver extends BlockModContainer {
|
||||
|
||||
IIcon iconBottom;
|
||||
IIcon iconTop;
|
||||
IIcon iconSides;
|
||||
|
||||
public BlockVisweaver() {
|
||||
super(Material.wood);
|
||||
setHardness(5F);
|
||||
setResistance(10F);
|
||||
|
||||
VisweaverRecipeMap.putRecipe(25, Aspect.FIRE, new ItemStack(Items.bed), new ItemStack(Items.spider_eye));
|
||||
VisweaverRecipeMap.putRecipe(50, Aspect.EARTH, new ItemStack(Items.brick), new ItemStack(Items.netherbrick));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> getTileEntity() {
|
||||
return TileVisweaver.class;
|
||||
}
|
||||
|
||||
@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) {
|
||||
par1World.markBlockForUpdate(par2, par3, par4);
|
||||
par5EntityPlayer
|
||||
.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_VISWEAVER, par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return Blocks.planks.getIcon(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int var2) {
|
||||
return new TileVisweaver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Object> getSpecialParameters() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName() {
|
||||
return VISWEAVER;
|
||||
}
|
||||
|
||||
// Only register as part of the GTNH modpack
|
||||
@Override
|
||||
public boolean shouldRegister() {
|
||||
// return Loader.isModLoaded("dreamcraft");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplayInTab() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return LibRenderIDs.idVisweaver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRegisterableResearch getResearchItem() {
|
||||
return (IRegisterableResearch) new TTResearchItem(
|
||||
LibResearch.KEY_VISWEAVER,
|
||||
new AspectList().add(Aspect.FIRE, 1).add(Aspect.WATER, 1).add(Aspect.EARTH, 1).add(Aspect.AIR, 1)
|
||||
.add(Aspect.ORDER, 1).add(Aspect.ENTROPY, 1),
|
||||
-4,
|
||||
0,
|
||||
2,
|
||||
new ItemStack(this)).setParents(LibResearch.KEY_SPELL_CLOTH)
|
||||
.setPages(new ResearchPage("0"), ResearchHelper.infusionPage(LibResearch.KEY_VISWEAVER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThaumicTinkererRecipe getRecipeItem() {
|
||||
return new ThaumicTinkererInfusionRecipe(
|
||||
LibResearch.KEY_VISWEAVER,
|
||||
new ItemStack(this),
|
||||
15,
|
||||
new AspectList().add(Aspect.MAGIC, 50).add(Aspect.ENERGY, 20).add(Aspect.ELDRITCH, 20)
|
||||
.add(Aspect.VOID, 20).add(Aspect.MIND, 10),
|
||||
new ItemStack(Items.bed),
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 1),
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 1),
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 1),
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 1),
|
||||
new ItemStack(ConfigBlocks.blockCosmeticSolid, 1, 1),
|
||||
new ItemStack(ConfigItems.itemResource, 1, 2),
|
||||
new ItemStack(ConfigItems.itemResource, 1, 2),
|
||||
new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemSpellCloth.class)));
|
||||
}
|
||||
}
|
||||
@@ -130,17 +130,16 @@ public class BlockBedrockPortal extends BlockMod {
|
||||
(EntityPlayerMP) entity,
|
||||
ConfigHandler.bedrockDimensionID,
|
||||
new TeleporterBedrock((WorldServer) par1World));
|
||||
if (entity.worldObj.getBlock(par2, 250, par4) == Blocks.bedrock) {
|
||||
entity.worldObj.setBlock(par2, 250, par4, Blocks.air);
|
||||
if (entity.worldObj.isAirBlock(par2, 249, par4)) {
|
||||
entity.worldObj.setBlock(par2, 249, par4, Blocks.stone);
|
||||
}
|
||||
if (entity.worldObj.getBlock(par2, 251, par4) == Blocks.bedrock) {
|
||||
entity.worldObj.setBlock(par2, 251, par4, Blocks.air);
|
||||
}
|
||||
if (entity.worldObj.getBlock(par2, 252, par4) == Blocks.bedrock) {
|
||||
entity.worldObj.setBlock(par2, 252, par4, Blocks.air);
|
||||
}
|
||||
if (entity.worldObj.getBlock(par2, 253, par4) == Blocks.bedrock) {
|
||||
entity.worldObj.setBlock(par2, 253, par4, Blocks.air);
|
||||
for (int i = 250; i < 254; i++) {
|
||||
Block block = entity.worldObj.getBlock(par2, i, par4);
|
||||
// something seems to be turning our bedrock to plain stone
|
||||
// let's also check that
|
||||
if (block == Blocks.stone || block == Blocks.bedrock) {
|
||||
entity.worldObj.setBlockToAir(par2, i, par4);
|
||||
}
|
||||
}
|
||||
if (entity.worldObj.getBlock(par2, 254, par4) == Blocks.bedrock) {
|
||||
entity.worldObj.setBlock(par2, 254, par4, this);
|
||||
|
||||
@@ -37,7 +37,8 @@ import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager;
|
||||
import thaumic.tinkerer.common.lib.LibBlockNames;
|
||||
|
||||
@Optional.InterfaceList({ @Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers"),
|
||||
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") })
|
||||
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"),
|
||||
@Optional.Interface(iface = "appeng.api.movable.IMovableTile", modid = "appliedenergistics2") })
|
||||
public class TileAspectAnalyzer extends TileEntity implements IInventory, SimpleComponent, IPeripheral, IMovableTile {
|
||||
|
||||
ItemStack[] inventorySlots = new ItemStack[1];
|
||||
@@ -230,11 +231,13 @@ public class TileAspectAnalyzer extends TileEntity implements IInventory, Simple
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public boolean prepareToMove() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public void doneMoving() {}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,9 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
@Optional.Interface(iface = "appeng.api.movable.IMovableTile", modid = "appliedenergistics2")
|
||||
public class TileCamo extends TileEntity implements IMovableTile {
|
||||
|
||||
private static final String TAG_CAMO = "camo";
|
||||
@@ -73,10 +75,12 @@ public class TileCamo extends TileEntity implements IMovableTile {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public boolean prepareToMove() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public void doneMoving() {}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
@@ -41,6 +42,7 @@ import thaumic.tinkerer.common.enchantment.core.EnchantmentManager;
|
||||
import thaumic.tinkerer.common.lib.LibBlockNames;
|
||||
import thaumic.tinkerer.common.lib.LibFeatures;
|
||||
|
||||
@Optional.Interface(iface = "appeng.api.movable.IMovableTile", modid = "appliedenergistics2")
|
||||
public class TileEnchanter extends TileEntity implements ISidedInventory, IMovableTile {
|
||||
|
||||
private static final String TAG_ENCHANTS = "enchantsIntArray";
|
||||
@@ -494,10 +496,12 @@ public class TileEnchanter extends TileEntity implements ISidedInventory, IMovab
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public boolean prepareToMove() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public void doneMoving() {}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.IAppEngApi;
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import thaumic.tinkerer.common.ThaumicTinkerer;
|
||||
import thaumic.tinkerer.common.block.mobilizer.BlockMobilizer;
|
||||
|
||||
@@ -117,16 +117,13 @@ public class TileEntityMobilizer extends TileEntity {
|
||||
if (!worldObj.isRemote) {
|
||||
|
||||
TileEntity passenger = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
IAppEngApi api = AEApi.instance();
|
||||
|
||||
// Prevent the passenger from popping off. Not sent to clients.
|
||||
worldObj.setBlock(targetX, yCoord, targetZ, Block.getBlockFromName("stone"), 0, 0);
|
||||
// Move non-TE blocks
|
||||
Block passengerId = worldObj.getBlock(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
if (worldObj.isAirBlock(xCoord, yCoord + 1, zCoord)
|
||||
|| passengerId.canPlaceBlockAt(worldObj, targetX, yCoord + 1, targetZ)) {
|
||||
|
||||
if (passenger == null) {
|
||||
if (passengerId != Block.getBlockFromName("bedrock")
|
||||
&& passengerId != Block.getBlockFromName("")) {
|
||||
@@ -143,7 +140,8 @@ public class TileEntityMobilizer extends TileEntity {
|
||||
}
|
||||
}
|
||||
// If AE is installed, use its handler
|
||||
} else if (api != null) {
|
||||
} else if (Loader.isModLoaded("appliedenergistics2")) {
|
||||
IAppEngApi api = AEApi.instance();
|
||||
if (api.registries().movable().askToMove(passenger)) {
|
||||
worldObj.setBlock(
|
||||
targetX,
|
||||
@@ -159,34 +157,29 @@ public class TileEntityMobilizer extends TileEntity {
|
||||
api.registries().movable().doneMoving(passenger);
|
||||
passenger.validate();
|
||||
}
|
||||
|
||||
// Handler IMovableTiles and vanilla TEs without AE
|
||||
} else if (passenger instanceof IMovableTile
|
||||
|| passenger.getClass().getName().startsWith("net.minecraft.tileentity")) {
|
||||
boolean imovable = passenger instanceof IMovableTile;
|
||||
if (imovable) ((IMovableTile) passenger).prepareToMove();
|
||||
worldObj.setBlock(
|
||||
targetX,
|
||||
yCoord + 1,
|
||||
targetZ,
|
||||
worldObj.getBlock(xCoord, yCoord + 1, zCoord),
|
||||
worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord),
|
||||
3);
|
||||
passenger.invalidate();
|
||||
worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord);
|
||||
} else if (passenger.getClass().getName().startsWith("net.minecraft.tileentity")) {
|
||||
worldObj.setBlock(
|
||||
targetX,
|
||||
yCoord + 1,
|
||||
targetZ,
|
||||
worldObj.getBlock(xCoord, yCoord + 1, zCoord),
|
||||
worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord),
|
||||
3);
|
||||
passenger.invalidate();
|
||||
worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
// IMovableHandler default code
|
||||
Chunk c = worldObj.getChunkFromBlockCoords(targetX, targetZ);
|
||||
// IMovableHandler default code
|
||||
Chunk c = worldObj.getChunkFromBlockCoords(targetX, targetZ);
|
||||
|
||||
c.func_150812_a(targetX & 0xF, yCoord + 1, targetZ & 0xF, passenger);
|
||||
c.func_150812_a(targetX & 0xF, yCoord + 1, targetZ & 0xF, passenger);
|
||||
|
||||
if (c.isChunkLoaded) {
|
||||
worldObj.addTileEntity(passenger);
|
||||
worldObj.markBlockForUpdate(targetX, yCoord + 1, targetZ);
|
||||
}
|
||||
if (imovable) ((IMovableTile) passenger).doneMoving();
|
||||
passenger.validate();
|
||||
}
|
||||
if (c.isChunkLoaded) {
|
||||
worldObj.addTileEntity(passenger);
|
||||
worldObj.markBlockForUpdate(targetX, yCoord + 1, targetZ);
|
||||
}
|
||||
passenger.validate();
|
||||
}
|
||||
}
|
||||
// Move self
|
||||
this.invalidate();
|
||||
|
||||
@@ -5,8 +5,10 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import thaumic.tinkerer.common.ThaumicTinkerer;
|
||||
|
||||
@Optional.Interface(iface = "appeng.api.movable.IMovableTile", modid = "appliedenergistics2")
|
||||
public class TileEntityRelay extends TileEntity implements IMovableTile {
|
||||
|
||||
public boolean hasPartner;
|
||||
@@ -137,10 +139,12 @@ public class TileEntityRelay extends TileEntity implements IMovableTile {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public boolean prepareToMove() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public void doneMoving() {}
|
||||
}
|
||||
@@ -26,15 +26,18 @@ import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.aspects.IAspectContainer;
|
||||
import thaumcraft.api.aspects.IEssentiaContainerItem;
|
||||
import thaumcraft.common.blocks.ItemJarFilled;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.tiles.TileJarFillable;
|
||||
import thaumcraft.common.tiles.TileJarFillableVoid;
|
||||
import thaumic.tinkerer.common.lib.LibBlockNames;
|
||||
|
||||
@Optional.Interface(iface = "appeng.api.movable.IMovableTile", modid = "appliedenergistics2")
|
||||
public class TileFunnel extends TileEntity implements ISidedInventory, IAspectContainer, IMovableTile {
|
||||
|
||||
ItemStack[] inventorySlots = new ItemStack[1];
|
||||
@@ -51,7 +54,7 @@ public class TileFunnel extends TileEntity implements ISidedInventory, IAspectCo
|
||||
Aspect aspect = aspectList.getAspects()[0];
|
||||
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
if (tile != null && tile instanceof TileEntityHopper) {
|
||||
if (tile instanceof TileEntityHopper) {
|
||||
TileEntity tile1 = getHopperFacing(
|
||||
tile.xCoord,
|
||||
tile.yCoord,
|
||||
@@ -69,6 +72,18 @@ public class TileFunnel extends TileEntity implements ISidedInventory, IAspectCo
|
||||
jar1.addToContainer(aspect, 1);
|
||||
item.setAspects(jar, aspectList.remove(aspect, 1));
|
||||
}
|
||||
// "AspectFilter" is used for the jar label
|
||||
if (aspectList.getAmount(aspectList.getAspects()[0]) == 0
|
||||
&& !jar.stackTagCompound.hasKey("AspectFilter")) {
|
||||
String itemName = jar.getUnlocalizedName();
|
||||
if (itemName.equals("item.BlockJarFilledItem")) {
|
||||
setInventorySlotContents(0, new ItemStack(ConfigBlocks.blockJar));
|
||||
} else if (itemName.equals("item.BlockJarFilledItem.void")) {
|
||||
setInventorySlotContents(0, new ItemStack(ConfigBlocks.blockJar));
|
||||
getStackInSlot(0).setItemDamage(3);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,10 +292,12 @@ public class TileFunnel extends TileEntity implements ISidedInventory, IAspectCo
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public boolean prepareToMove() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public void doneMoving() {}
|
||||
}
|
||||
@@ -34,7 +34,8 @@ import thaumic.tinkerer.common.ThaumicTinkerer;
|
||||
import thaumic.tinkerer.common.core.helper.MiscHelper;
|
||||
|
||||
@Optional.InterfaceList({ @Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers"),
|
||||
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") })
|
||||
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"),
|
||||
@Optional.Interface(iface = "appeng.api.movable.IMovableTile", modid = "appliedenergistics2") })
|
||||
public class TileMagnet extends TileEntity implements IPeripheral, IMovableTile, SimpleComponent {
|
||||
|
||||
@Override
|
||||
@@ -146,11 +147,13 @@ public class TileMagnet extends TileEntity implements IPeripheral, IMovableTile,
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public boolean prepareToMove() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public void doneMoving() {}
|
||||
|
||||
@Callback(doc = "function():boolean -- Returns Whether magnet is pushing or pulling")
|
||||
|
||||
@@ -34,6 +34,7 @@ import li.cil.oc.api.machine.Context;
|
||||
import thaumic.tinkerer.common.item.ItemSoulMould;
|
||||
import thaumic.tinkerer.common.lib.LibBlockNames;
|
||||
|
||||
@Optional.Interface(iface = "appeng.api.movable.IMovableTile", modid = "appliedenergistics2")
|
||||
public class TileMobMagnet extends TileMagnet implements IInventory, IMovableTile {
|
||||
|
||||
private static final String TAG_ADULT = "adultCheck";
|
||||
@@ -230,10 +231,12 @@ public class TileMobMagnet extends TileMagnet implements IInventory, IMovableTil
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public boolean prepareToMove() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public void doneMoving() {}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
@@ -38,7 +39,7 @@ import thaumic.tinkerer.common.core.handler.ConfigHandler;
|
||||
import thaumic.tinkerer.common.lib.LibBlockNames;
|
||||
|
||||
/* import thaumic.tinkerer.common.compat.TinkersConstructCompat; */
|
||||
|
||||
@Optional.Interface(iface = "appeng.api.movable.IMovableTile", modid = "appliedenergistics2")
|
||||
public class TileRepairer extends TileEntity
|
||||
implements ISidedInventory, IAspectContainer, IEssentiaTransport, IMovableTile {
|
||||
|
||||
@@ -376,10 +377,12 @@ public class TileRepairer extends TileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public boolean prepareToMove() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public void doneMoving() {}
|
||||
}
|
||||
@@ -1,276 +0,0 @@
|
||||
package thaumic.tinkerer.common.block.tile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.visnet.VisNetHandler;
|
||||
import thaumic.tinkerer.api.VisweaverRecipe;
|
||||
import thaumic.tinkerer.api.VisweaverRecipeMap;
|
||||
import thaumic.tinkerer.common.lib.LibBlockNames;
|
||||
|
||||
public class TileVisweaver extends TileEntity implements IInventory {
|
||||
|
||||
private static final String TAG_INTERNAL_VIS = "internalVis";
|
||||
private static final String TAG_REQUIRED_VIS = "requiredVis";
|
||||
private static final String TAG_WORKING = "working";
|
||||
private static final String TAG_ASPECT = "cvType";
|
||||
private static final String TAG_INPUT = "currentInput";
|
||||
private static final String TAG_OUTPUT = "currentOutput";
|
||||
|
||||
private int tickCounter;
|
||||
private int internalVis = 0;
|
||||
private boolean working = false;
|
||||
private ItemStack currentOutput;
|
||||
private ItemStack currentInput;
|
||||
private Aspect cvType;
|
||||
private int requiredVis;
|
||||
|
||||
ItemStack[] inventorySlots = new ItemStack[2];
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
tickCounter++;
|
||||
if (worldObj.isRemote) return;
|
||||
if (working) {
|
||||
ItemStack currentStack = getStackInSlot(0);
|
||||
if (currentStack == null || currentInput == null || !currentStack.isItemEqual(currentInput)) {
|
||||
flushRecipe();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
if (tickCounter % 20 != 0) return;
|
||||
if (!working) {
|
||||
recipeCheck();
|
||||
} else {
|
||||
internalVis += VisNetHandler.drainVis(this.worldObj, this.xCoord, this.yCoord, this.zCoord, cvType, 500);
|
||||
progressRecipe();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
private void progressRecipe() {
|
||||
if (internalVis >= requiredVis) {
|
||||
internalVis -= requiredVis;
|
||||
finishRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
private void flushRecipe() {
|
||||
internalVis = 0;
|
||||
requiredVis = 0;
|
||||
currentOutput = null;
|
||||
currentInput = null;
|
||||
cvType = null;
|
||||
working = false;
|
||||
}
|
||||
|
||||
private void recipeCheck() {
|
||||
VisweaverRecipe recipe = VisweaverRecipeMap.lookup(getStackInSlot(0));
|
||||
if (recipe != null) {
|
||||
ItemStack output = recipe.getOutput();
|
||||
if (canAddToSlot(output, 1) <= 0) return;
|
||||
cvType = recipe.getCentivisType();
|
||||
requiredVis = recipe.getCentivisCost();
|
||||
currentOutput = output;
|
||||
currentInput = recipe.getInput();
|
||||
working = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void finishRecipe() {
|
||||
decrStackSize(0, 1);
|
||||
addToSlot(currentOutput, 1);
|
||||
ItemStack input = getStackInSlot(0);
|
||||
if (input != null && currentInput.isItemEqual(input) && canAddToSlot(currentOutput, 1) > 0) {
|
||||
progressRecipe();
|
||||
} else {
|
||||
flushRecipe();
|
||||
recipeCheck();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventorySlots.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIn) {
|
||||
return inventorySlots[slotIn];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (inventorySlots[i] != null) {
|
||||
ItemStack stackAt;
|
||||
|
||||
if (inventorySlots[i].stackSize <= j) {
|
||||
stackAt = inventorySlots[i];
|
||||
inventorySlots[i] = null;
|
||||
} else {
|
||||
stackAt = inventorySlots[i].splitStack(j);
|
||||
|
||||
if (inventorySlots[i].stackSize == 0) inventorySlots[i] = null;
|
||||
|
||||
}
|
||||
return stackAt;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of items from the input stack that can be stacked into this slot
|
||||
*/
|
||||
public int canAddToSlot(ItemStack input, int slot) {
|
||||
ItemStack currentStack = getStackInSlot(slot);
|
||||
if (currentStack == null) return Math.min(64, input.stackSize);
|
||||
if (!currentStack.isItemEqual(input)) return 0;
|
||||
return Math.min(input.stackSize, 64 - currentStack.stackSize);
|
||||
}
|
||||
|
||||
public void addToSlot(ItemStack stack, int slot) {
|
||||
int movable = canAddToSlot(stack, slot);
|
||||
if (movable == 0) return;
|
||||
ItemStack currentStack = getStackInSlot(slot);
|
||||
ItemStack newStack = stack.copy();
|
||||
|
||||
if (currentStack == null) {
|
||||
newStack.stackSize = movable;
|
||||
setInventorySlotContents(slot, newStack);
|
||||
} else {
|
||||
currentStack.stackSize += movable;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack stack) {
|
||||
inventorySlots[i] = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return LibBlockNames.VISWEAVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this
|
||||
&& entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
readFromNBT(pkt.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
|
||||
working = par1NBTTagCompound.getBoolean(TAG_WORKING);
|
||||
internalVis = par1NBTTagCompound.getInteger(TAG_INTERNAL_VIS);
|
||||
requiredVis = par1NBTTagCompound.getInteger(TAG_REQUIRED_VIS);
|
||||
cvType = Aspect.getAspect(par1NBTTagCompound.getString(TAG_ASPECT));
|
||||
currentInput = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag(TAG_INPUT));
|
||||
currentOutput = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag(TAG_OUTPUT));
|
||||
|
||||
NBTTagList var2 = par1NBTTagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
inventorySlots = new ItemStack[getSizeInventory()];
|
||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
|
||||
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
|
||||
byte var5 = var4.getByte("Slot");
|
||||
if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
|
||||
NBTTagCompound input = new NBTTagCompound();
|
||||
NBTTagCompound output = new NBTTagCompound();
|
||||
|
||||
par1NBTTagCompound.setBoolean(TAG_WORKING, working);
|
||||
par1NBTTagCompound.setInteger(TAG_INTERNAL_VIS, internalVis);
|
||||
par1NBTTagCompound.setInteger(TAG_REQUIRED_VIS, requiredVis);
|
||||
|
||||
if (working) {
|
||||
par1NBTTagCompound.setString(TAG_ASPECT, cvType.getTag());
|
||||
par1NBTTagCompound.setTag(TAG_INPUT, currentInput.writeToNBT(input));
|
||||
par1NBTTagCompound.setTag(TAG_OUTPUT, currentOutput.writeToNBT(output));
|
||||
}
|
||||
|
||||
NBTTagList var2 = new NBTTagList();
|
||||
for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
|
||||
if (inventorySlots[var3] != null) {
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setByte("Slot", (byte) var3);
|
||||
inventorySlots[var3].writeToNBT(var4);
|
||||
var2.appendTag(var4);
|
||||
}
|
||||
}
|
||||
par1NBTTagCompound.setTag("Items", var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public S35PacketUpdateTileEntity getDescriptionPacket() {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writeToNBT(nbttagcompound);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
return index == 0;
|
||||
}
|
||||
|
||||
public boolean isWorking() {
|
||||
return working;
|
||||
}
|
||||
|
||||
public int getTickCounter() {
|
||||
return tickCounter;
|
||||
}
|
||||
|
||||
public Aspect getCvType() {
|
||||
return cvType;
|
||||
}
|
||||
|
||||
public int getInternalVis() {
|
||||
return internalVis;
|
||||
}
|
||||
|
||||
public int getRequiredVis() {
|
||||
return requiredVis;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package thaumic.tinkerer.common.block.tile.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import thaumic.tinkerer.common.block.tile.TileVisweaver;
|
||||
|
||||
public class ContainerVisweaver extends ContainerPlayerInv {
|
||||
|
||||
TileVisweaver visweaver;
|
||||
|
||||
public ContainerVisweaver(TileVisweaver visweaver, InventoryPlayer playerInv) {
|
||||
super(playerInv);
|
||||
this.visweaver = visweaver;
|
||||
|
||||
addSlotToContainer(new Slot(visweaver, 0, 20, 30));
|
||||
addSlotToContainer(new SlotVisweaverOutput(visweaver, 1, 140, 30));
|
||||
|
||||
initPlayerInv();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
itemstack = stackInSlot.copy();
|
||||
|
||||
if (index == 0 || index == 1) {
|
||||
if (!this.mergeItemStack(stackInSlot, 2, 38, true)) {
|
||||
return null;
|
||||
}
|
||||
slot.onSlotChange(stackInSlot, itemstack);
|
||||
} else {
|
||||
if (!this.mergeItemStack(stackInSlot, 0, 1, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (stackInSlot.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (stackInSlot.stackSize == itemstack.stackSize) {
|
||||
return null;
|
||||
}
|
||||
slot.onPickupFromSlot(player, stackInSlot);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return visweaver.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
public static class SlotVisweaverOutput extends Slot {
|
||||
|
||||
public SlotVisweaverOutput(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) {
|
||||
super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -29,13 +29,11 @@ public class ContainerIchorPouch extends ContainerPlayerInv {
|
||||
ItemStack pouch;
|
||||
int blockSlot;
|
||||
|
||||
public ContainerIchorPouch(EntityPlayer player) {
|
||||
public ContainerIchorPouch(EntityPlayer player, ItemStack bag) {
|
||||
super(player.inventory);
|
||||
|
||||
pouch = bag;
|
||||
this.player = player;
|
||||
pouch = player.getCurrentEquippedItem();
|
||||
blockSlot = player.inventory.currentItem + 27 + 13 * 9;
|
||||
|
||||
for (int y = 0; y < 9; y++) for (int x = 0; x < 13; x++)
|
||||
addSlotToContainer(new SlotNoPouches(inv, y * 13 + x, 12 + x * 18, 8 + y * 18));
|
||||
initPlayerInv();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
+393
-399
@@ -11,390 +11,398 @@
|
||||
*/
|
||||
package thaumic.tinkerer.common.block.tile.tablet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemReed;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.server.management.ItemInWorldManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import gregtech.common.tileentities.machines.basic.MTEWorldAccelerator;
|
||||
import li.cil.oc.api.machine.Arguments;
|
||||
import li.cil.oc.api.machine.Callback;
|
||||
import li.cil.oc.api.machine.Context;
|
||||
import li.cil.oc.api.network.SimpleComponent;
|
||||
import thaumic.tinkerer.common.ThaumicTinkerer;
|
||||
import thaumic.tinkerer.common.block.BlockAnimationTablet;
|
||||
import thaumic.tinkerer.common.lib.LibBlockNames;
|
||||
import thaumic.tinkerer.common.registry.TTRegistry;
|
||||
import thaumic.tinkerer.mixins.early.AccessorItemInWorldManager;
|
||||
|
||||
@Optional.InterfaceList({ @Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers"),
|
||||
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") })
|
||||
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"),
|
||||
@Optional.Interface(iface = "appeng.api.movable.IMovableTile", modid = "appliedenergistics2") })
|
||||
public class TileAnimationTablet extends TileEntity implements IInventory, IMovableTile, IPeripheral, SimpleComponent {
|
||||
|
||||
private static final String TAG_LEFT_CLICK = "leftClick";
|
||||
private static final String TAG_REDSTONE = "redstone";
|
||||
private static final String TAG_PROGRESS = "progress";
|
||||
private static final String TAG_MOD = "mod";
|
||||
private static final String TAG_OWNER = "owner";
|
||||
|
||||
private static final int[][] LOC_INCREASES = new int[][] { { 0, -1 }, { 0, +1 }, { -1, 0 }, { +1, 0 } };
|
||||
|
||||
private static final ForgeDirection[] SIDES = new ForgeDirection[] { ForgeDirection.NORTH, ForgeDirection.SOUTH,
|
||||
ForgeDirection.WEST, ForgeDirection.EAST };
|
||||
|
||||
private static final int SWING_SPEED = 3;
|
||||
private static final int MAX_DEGREE = 45;
|
||||
public double ticksExisted = 0;
|
||||
private static final byte SWING_SPEED = 3;
|
||||
private static final byte MAX_DEGREE = 45;
|
||||
private static final byte MAX_ITERATIONS = MAX_DEGREE / SWING_SPEED;
|
||||
public boolean leftClick = true;
|
||||
public boolean redstone = false;
|
||||
public int swingProgress = 0;
|
||||
List<Entity> detectedEntities = new ArrayList<>();
|
||||
ItemStack[] inventorySlots = new ItemStack[1];
|
||||
// public String Owner;
|
||||
TabletFakePlayer player;
|
||||
private int swingMod = 0;
|
||||
private byte prevSwingProgress;
|
||||
private byte swingProgress;
|
||||
private byte swingMod;
|
||||
|
||||
public ItemStack heldItem;
|
||||
|
||||
private TabletFakePlayer player;
|
||||
private boolean isBreaking = false;
|
||||
private int initialDamage = 0;
|
||||
private int curblockDamage = 0;
|
||||
private int durabilityRemainingOnBlock;
|
||||
private int ticksElapsed;
|
||||
private int prevTicksElapsed;
|
||||
|
||||
private final Vec3 tempVec = Vec3.createVectorHelper(0, 0, 0);
|
||||
private final Vec3 positionVec = Vec3.createVectorHelper(0, 0, 0);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final float getRenderSwingProgress(float partialTicks) {
|
||||
return prevSwingProgress + (swingProgress - prevSwingProgress) * partialTicks;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final float getTicksExisted(float partialTicks) {
|
||||
return prevTicksElapsed + (ticksElapsed - prevTicksElapsed) * partialTicks;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final int getWorldAcceleratorBonus() {
|
||||
return (ticksElapsed - prevTicksElapsed) - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
// player = new TabletFakePlayer(this);//,Owner);
|
||||
player.onUpdate();
|
||||
player.inventory.clearInventory(null, -1);
|
||||
ticksExisted++;
|
||||
if (worldObj.isRemote) {
|
||||
prevSwingProgress = swingProgress;
|
||||
prevTicksElapsed = ticksElapsed;
|
||||
int iterations = ThaumicTinkerer.gtLoaded ? MTEWorldAccelerator.getAccelerationForTEUnsafe(this) + 1 : 1;
|
||||
ticksElapsed += iterations;
|
||||
ItemStack stack = heldItem;
|
||||
if (stack != null) {
|
||||
iterations = Math.min(iterations, MAX_ITERATIONS);
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
swingProgress += swingMod;
|
||||
if (swingProgress >= MAX_DEGREE) {
|
||||
swingMod = -SWING_SPEED;
|
||||
} else if (swingProgress <= 0) {
|
||||
stopSwinging();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stopSwinging();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = getStackInSlot(0);
|
||||
try {
|
||||
player.onUpdate();
|
||||
|
||||
if (stack != null) {
|
||||
if (swingProgress >= MAX_DEGREE) swingHit();
|
||||
ItemStack stack = heldItem;
|
||||
if (stack == null) {
|
||||
if (isBreaking) stopBreaking();
|
||||
stopSwinging();
|
||||
return;
|
||||
}
|
||||
|
||||
swingMod = swingProgress <= 0 ? 0 : swingProgress >= MAX_DEGREE ? -SWING_SPEED : swingMod;
|
||||
MovingObjectPosition hit = calculateHit();
|
||||
swingProgress += swingMod;
|
||||
if (swingProgress < 0) swingProgress = 0;
|
||||
} else {
|
||||
swingMod = 0;
|
||||
swingProgress = 0;
|
||||
if (swingProgress >= MAX_DEGREE) {
|
||||
if (hit != null) {
|
||||
swingHit(stack, hit);
|
||||
}
|
||||
swingMod = -SWING_SPEED;
|
||||
} else if (swingProgress <= 0) {
|
||||
stopSwinging();
|
||||
}
|
||||
|
||||
if (isBreaking) stopBreaking();
|
||||
}
|
||||
|
||||
boolean detect = detect();
|
||||
if (!detect) stopBreaking();
|
||||
|
||||
if (detect && isBreaking) continueBreaking();
|
||||
|
||||
if ((!redstone || isBreaking) && detect && swingProgress == 0) {
|
||||
initiateSwing();
|
||||
worldObj.addBlockEvent(
|
||||
xCoord,
|
||||
yCoord,
|
||||
zCoord,
|
||||
ThaumicTinkerer.registry.getFirstBlockFromClass(BlockAnimationTablet.class),
|
||||
0,
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
public void initiateSwing() {
|
||||
swingMod = SWING_SPEED;
|
||||
swingProgress = 1;
|
||||
}
|
||||
|
||||
public void swingHit() {
|
||||
ChunkCoordinates coords = getTargetLoc();
|
||||
ItemStack stack = getStackInSlot(0);
|
||||
Item item = stack.getItem();
|
||||
Block block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ);
|
||||
|
||||
player.setCurrentItemOrArmor(0, stack);
|
||||
|
||||
boolean done = false;
|
||||
|
||||
if (leftClick) {
|
||||
Entity entity = detectedEntities.isEmpty() ? null
|
||||
: detectedEntities.get(worldObj.rand.nextInt(detectedEntities.size()));
|
||||
if (entity != null) {
|
||||
player.getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers()); // Set attack strenght
|
||||
player.attackTargetEntityWithCurrentItem(entity);
|
||||
done = true;
|
||||
} else if (!isBreaking) {
|
||||
if (block != Blocks.air && !block.isAir(worldObj, coords.posX, coords.posY, coords.posZ)
|
||||
&& block.getBlockHardness(worldObj, coords.posX, coords.posY, coords.posZ) >= 0) {
|
||||
isBreaking = true;
|
||||
startBreaking(block, worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ));
|
||||
done = true;
|
||||
if (isBreaking) {
|
||||
if (hit == null || hit.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
stopBreaking();
|
||||
return;
|
||||
}
|
||||
ItemInWorldManager worldManager = player.theItemInWorldManager;
|
||||
worldManager.updateBlockRemoving();
|
||||
if (((AccessorItemInWorldManager) worldManager).getDurabilityRemainingOnBlock() >= 10) {
|
||||
worldManager.tryHarvestBlock(hit.blockX, hit.blockY, hit.blockZ);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int side = SIDES[(getBlockMetadata() & 7) - 2].getOpposite().ordinal();
|
||||
|
||||
if (!(block != Blocks.air && !block.isAir(worldObj, coords.posX, coords.posY, coords.posZ))) {
|
||||
coords.posY -= 1;
|
||||
side = ForgeDirection.UP.ordinal();
|
||||
block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ);
|
||||
}
|
||||
|
||||
try {
|
||||
ForgeEventFactory.onPlayerInteract(
|
||||
player,
|
||||
Action.RIGHT_CLICK_AIR,
|
||||
coords.posX,
|
||||
coords.posY,
|
||||
coords.posZ,
|
||||
side,
|
||||
worldObj);
|
||||
Entity entity = detectedEntities.isEmpty() ? null
|
||||
: detectedEntities.get(worldObj.rand.nextInt(detectedEntities.size()));
|
||||
done = entity != null && entity instanceof EntityLiving
|
||||
&& (item.itemInteractionForEntity(stack, player, (EntityLivingBase) entity)
|
||||
|| (!(entity instanceof EntityAnimal) || ((EntityAnimal) entity).interact(player)));
|
||||
|
||||
if (!done) item.onItemUseFirst(
|
||||
stack,
|
||||
player,
|
||||
worldObj,
|
||||
coords.posX,
|
||||
coords.posY,
|
||||
coords.posZ,
|
||||
side,
|
||||
0F,
|
||||
0F,
|
||||
0F);
|
||||
if (!done) done = block != null && block
|
||||
.onBlockActivated(worldObj, coords.posX, coords.posY, coords.posZ, player, side, 0F, 0F, 0F);
|
||||
if (!done) done = item
|
||||
.onItemUse(stack, player, worldObj, coords.posX, coords.posY, coords.posZ, side, 0F, 0F, 0F);
|
||||
if (!done) {
|
||||
item.onItemRightClick(stack, worldObj, player);
|
||||
done = true;
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
List list = worldObj.getEntitiesWithinAABB(
|
||||
EntityPlayer.class,
|
||||
AxisAlignedBB.getBoundingBox(
|
||||
xCoord - 8,
|
||||
yCoord - 8,
|
||||
zCoord - 8,
|
||||
xCoord + 8,
|
||||
yCoord + 8,
|
||||
zCoord + 8));
|
||||
for (Object player : list) {
|
||||
((EntityPlayer) player).addChatComponentMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.RED
|
||||
+ "Something went wrong with a Tool Dynamism Tablet! Check your FML log."));
|
||||
((EntityPlayer) player).addChatComponentMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.RED + "" + EnumChatFormatting.ITALIC + e.getMessage()));
|
||||
if (isIdle() && hit != null && (!redstone || isBreaking)) {
|
||||
if (hit.typeOfHit == MovingObjectPosition.MovingObjectType.MISS
|
||||
&& (leftClick || !canPlaceItem(stack))) {
|
||||
return;
|
||||
}
|
||||
initiateSwing();
|
||||
}
|
||||
}
|
||||
|
||||
if (done) {
|
||||
stack = player.getCurrentEquippedItem();
|
||||
if (stack == null || stack.stackSize <= 0) setInventorySlotContents(0, null);
|
||||
else if (stack != getStackInSlot(0)) setInventorySlotContents(0, stack);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
// Copied from ItemInWorldManager, seems to do the trick.
|
||||
private void stopBreaking() {
|
||||
isBreaking = false;
|
||||
ChunkCoordinates coords = getTargetLoc();
|
||||
worldObj.destroyBlockInWorldPartially(player.getEntityId(), coords.posX, coords.posY, coords.posZ, -1);
|
||||
}
|
||||
|
||||
// Copied from ItemInWorldManager, seems to do the trick.
|
||||
private void startBreaking(Block block, int meta) {
|
||||
int side = SIDES[(getBlockMetadata() & 7) - 2].getOpposite().ordinal();
|
||||
ChunkCoordinates coords = getTargetLoc();
|
||||
|
||||
PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(
|
||||
player,
|
||||
Action.LEFT_CLICK_BLOCK,
|
||||
coords.posX,
|
||||
coords.posY,
|
||||
coords.posZ,
|
||||
side,
|
||||
worldObj);
|
||||
if (event.isCanceled()) {
|
||||
stopBreaking();
|
||||
return;
|
||||
}
|
||||
|
||||
initialDamage = curblockDamage;
|
||||
float var5 = 1F;
|
||||
|
||||
if (block != null) {
|
||||
if (event.useBlock != Event.Result.DENY)
|
||||
block.onBlockClicked(worldObj, coords.posX, coords.posY, coords.posZ, player);
|
||||
var5 = block.getPlayerRelativeBlockHardness(player, worldObj, coords.posX, coords.posY, coords.posZ);
|
||||
}
|
||||
|
||||
if (event.useItem == Event.Result.DENY) {
|
||||
stopBreaking();
|
||||
return;
|
||||
}
|
||||
|
||||
if (var5 >= 1F) {
|
||||
tryHarvestBlock(coords.posX, coords.posY, coords.posZ);
|
||||
stopBreaking();
|
||||
} else {
|
||||
int var7 = (int) (var5 * 10);
|
||||
worldObj.destroyBlockInWorldPartially(player.getEntityId(), coords.posX, coords.posY, coords.posZ, var7);
|
||||
durabilityRemainingOnBlock = var7;
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from ItemInWorldManager, seems to do the trick.
|
||||
private void continueBreaking() {
|
||||
++curblockDamage;
|
||||
int var1;
|
||||
float var4;
|
||||
int var5;
|
||||
ChunkCoordinates coords = getTargetLoc();
|
||||
|
||||
var1 = curblockDamage - initialDamage;
|
||||
Block block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ);
|
||||
|
||||
if (block == Blocks.air) stopBreaking();
|
||||
else {
|
||||
var4 = block.getPlayerRelativeBlockHardness(player, worldObj, coords.posX, coords.posY, coords.posZ) * var1;
|
||||
var5 = (int) (var4 * 10);
|
||||
|
||||
if (var5 != durabilityRemainingOnBlock) {
|
||||
worldObj.destroyBlockInWorldPartially(
|
||||
player.getEntityId(),
|
||||
coords.posX,
|
||||
coords.posY,
|
||||
coords.posZ,
|
||||
var5);
|
||||
durabilityRemainingOnBlock = var5;
|
||||
}
|
||||
|
||||
if (var4 >= 1F) {
|
||||
tryHarvestBlock(coords.posX, coords.posY, coords.posZ);
|
||||
stopBreaking();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
List<EntityPlayer> list = worldObj.getEntitiesWithinAABB(
|
||||
EntityPlayer.class,
|
||||
AxisAlignedBB
|
||||
.getBoundingBox(xCoord - 8, yCoord - 8, zCoord - 8, xCoord + 8, yCoord + 8, zCoord + 8));
|
||||
for (EntityPlayer player : list) {
|
||||
player.addChatComponentMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.RED
|
||||
+ "Something went wrong with a Tool Dynamism Tablet! Check your FML log."));
|
||||
player.addChatComponentMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.RED.toString() + EnumChatFormatting.ITALIC + e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from ItemInWorldManager, seems to do the trick.
|
||||
public boolean tryHarvestBlock(int par1, int par2, int par3) {
|
||||
ItemStack stack = getStackInSlot(0);
|
||||
if (stack != null && stack.getItem().onBlockStartBreak(stack, par1, par2, par3, player)) return false;
|
||||
|
||||
Block block = worldObj.getBlock(par1, par2, par3);
|
||||
int var5 = worldObj.getBlockMetadata(par1, par2, par3);
|
||||
// worldObj.playAuxSFXAtEntity(player, 2001, par1, par2, par3, var4 + (var5 << 12));
|
||||
boolean var6;
|
||||
|
||||
boolean var8 = false;
|
||||
if (block != null) var8 = block.canHarvestBlock(player, var5);
|
||||
|
||||
worldObj.loadedEntityList.size();
|
||||
if (stack != null) stack.getItem().onBlockDestroyed(stack, worldObj, block, par1, par2, par3, player);
|
||||
|
||||
var6 = removeBlock(par1, par2, par3);
|
||||
if (var6 && var8) block.harvestBlock(worldObj, player, par1, par2, par3, var5);
|
||||
|
||||
return var6;
|
||||
}
|
||||
|
||||
// Copied from ItemInWorldManager, seems to do the trick.
|
||||
private boolean removeBlock(int par1, int par2, int par3) {
|
||||
Block var4 = worldObj.getBlock(par1, par2, par3);
|
||||
int var5 = worldObj.getBlockMetadata(par1, par2, par3);
|
||||
|
||||
if (var4 != null) var4.onBlockHarvested(worldObj, par1, par2, par3, var5, player);
|
||||
|
||||
boolean var6 = var4 != null && var4.removedByPlayer(worldObj, player, par1, par2, par3);
|
||||
|
||||
if (var4 != null && var6) var4.onBlockDestroyedByPlayer(worldObj, par1, par2, par3, var5);
|
||||
|
||||
return var6;
|
||||
}
|
||||
|
||||
public boolean detect() {
|
||||
ChunkCoordinates coords = getTargetLoc();
|
||||
findEntities(coords);
|
||||
return !worldObj.isAirBlock(coords.posX, coords.posY, coords.posZ) || !detectedEntities.isEmpty();
|
||||
}
|
||||
|
||||
public void findEntities(ChunkCoordinates coords) {
|
||||
AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(
|
||||
coords.posX,
|
||||
coords.posY,
|
||||
coords.posZ,
|
||||
coords.posX + 1,
|
||||
coords.posY + 1,
|
||||
coords.posZ + 1);
|
||||
detectedEntities = worldObj.getEntitiesWithinAABB(Entity.class, boundingBox);
|
||||
private boolean canPlaceItem(ItemStack stack) {
|
||||
final Item item = stack.getItem();
|
||||
return item instanceof ItemBlock || item instanceof ItemReed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
player = new TabletFakePlayer(this);
|
||||
if (!worldObj.isRemote) {
|
||||
if (player == null) {
|
||||
player = new TabletFakePlayer(this);
|
||||
}
|
||||
player.worldObj = this.worldObj;
|
||||
}
|
||||
}
|
||||
|
||||
public ChunkCoordinates getTargetLoc() {
|
||||
ChunkCoordinates coords = new ChunkCoordinates(xCoord, yCoord, zCoord);
|
||||
private void swingHit(ItemStack stack, MovingObjectPosition hit) {
|
||||
if (leftClick) {
|
||||
if (hit.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
|
||||
player.attackTargetEntityWithCurrentItem(hit.entityHit);
|
||||
updateState();
|
||||
} else if (hit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
if (!isBreaking) {
|
||||
int x = hit.blockX;
|
||||
int y = hit.blockY;
|
||||
int z = hit.blockZ;
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
if (!block.isAir(worldObj, x, y, z) && block.getBlockHardness(worldObj, x, y, z) >= 0) {
|
||||
isBreaking = true;
|
||||
player.theItemInWorldManager.onBlockClicked(x, y, z, hit.sideHit);
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (hit.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
|
||||
if (player.interactWith(hit.entityHit)) {
|
||||
updateState();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int side = hit.sideHit;
|
||||
|
||||
int x = hit.blockX;
|
||||
int y = hit.blockY;
|
||||
int z = hit.blockZ;
|
||||
|
||||
// Copied from Minecraft's right click logic
|
||||
boolean result = !ForgeEventFactory
|
||||
.onPlayerInteract(player, PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, x, y, z, side, worldObj)
|
||||
.isCanceled();
|
||||
|
||||
if (result) {
|
||||
Vec3 hitVec = hit.hitVec;
|
||||
if (player.onPlayerRightClick(
|
||||
stack,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
side,
|
||||
(float) hitVec.xCoord,
|
||||
(float) hitVec.yCoord,
|
||||
(float) hitVec.zCoord)) {
|
||||
updateState();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (player.sendUseItem(stack)) {
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isIdle() {
|
||||
return swingMod == 0;
|
||||
}
|
||||
|
||||
public final boolean getIsBreaking() {
|
||||
return isBreaking;
|
||||
}
|
||||
|
||||
private void stopSwinging() {
|
||||
swingProgress = 0;
|
||||
swingMod = 0;
|
||||
}
|
||||
|
||||
// Copied from ItemInWorldManager, seems to do the trick.
|
||||
private void stopBreaking() {
|
||||
player.theItemInWorldManager.updateBlockRemoving();
|
||||
isBreaking = false;
|
||||
int[] increase = LOC_INCREASES[(getBlockMetadata() & 7) - 2];
|
||||
int x = xCoord + increase[0];
|
||||
int y = yCoord;
|
||||
int z = zCoord + increase[1];
|
||||
worldObj.destroyBlockInWorldPartially(player.getEntityId(), x, y, z, -1);
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
ItemStack stack = player.getHeldItem();
|
||||
if (stack == null || stack.stackSize <= 0) {
|
||||
this.heldItem = null;
|
||||
player.syncSlots();
|
||||
} else {
|
||||
this.heldItem = stack;
|
||||
}
|
||||
markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logic: Casts a ray between the player and the middle of the AABB to determine the side and hitVec. Works for both
|
||||
* entities and blocks. Whichever is closer takes priority.
|
||||
* <p>
|
||||
* This is similar to how Minecraft calculates the MovingObjectPosition, but instead of yaw/pitch I use the middle
|
||||
* of the bounding box to cover edge where blocks have a weird bounding box.
|
||||
* <p>
|
||||
* hit.typeOfHit will be MISS if it's targeting the block below (this is done so that placing blocks still properly
|
||||
* works).
|
||||
* <p>
|
||||
* This is an improvement to the old system, because it properly knows whether to hit an entity or block and also
|
||||
* passes in the proper parameters when interacting with a block (this has previously caused some issues with
|
||||
* certain blocks).
|
||||
*/
|
||||
private MovingObjectPosition calculateHit() {
|
||||
int meta = getBlockMetadata();
|
||||
if (meta == 0) {
|
||||
ThaumicTinkerer.log
|
||||
.error("Metadata of a Tool Dynamism tablet is in an invalid state. This is a critical error.");
|
||||
return coords;
|
||||
return null;
|
||||
}
|
||||
int[] increase = LOC_INCREASES[(meta & 7) - 2];
|
||||
coords.posX += increase[0];
|
||||
coords.posZ += increase[1];
|
||||
int x = xCoord + increase[0];
|
||||
int y = yCoord;
|
||||
int z = zCoord + increase[1];
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
|
||||
return coords;
|
||||
MovingObjectPosition hit = null;
|
||||
Vec3 position = positionVec;
|
||||
position.xCoord = xCoord + 0.5f;
|
||||
position.yCoord = yCoord + 0.5f;
|
||||
position.zCoord = zCoord + 0.5f;
|
||||
if (!worldObj.isAirBlock(x, y, z)) {
|
||||
AxisAlignedBB aabb = block.getCollisionBoundingBoxFromPool(worldObj, x, y, z);
|
||||
if (aabb != null) {
|
||||
hit = block.collisionRayTrace(worldObj, x, y, z, position, getMiddleOfAABB(aabb));
|
||||
}
|
||||
}
|
||||
List<Entity> entities = (List<Entity>) worldObj.getEntitiesWithinAABBExcludingEntity(
|
||||
player,
|
||||
AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1));
|
||||
if (!entities.isEmpty()) {
|
||||
double dist = hit == null ? Double.MAX_VALUE : position.squareDistanceTo(hit.hitVec);
|
||||
|
||||
Entity targetedEntity = null;
|
||||
Vec3 hitVec = null;
|
||||
for (Entity e : entities) {
|
||||
if (e.canBeCollidedWith()) {
|
||||
|
||||
float borderSize = e.getCollisionBorderSize();
|
||||
AxisAlignedBB aabb = e.boundingBox.expand(borderSize, borderSize, borderSize);
|
||||
MovingObjectPosition intercept = aabb.calculateIntercept(position, getMiddleOfAABB(aabb));
|
||||
|
||||
if (aabb.isVecInside(position)) {
|
||||
targetedEntity = e;
|
||||
hitVec = intercept == null ? position : intercept.hitVec;
|
||||
break;
|
||||
}
|
||||
if (intercept != null) {
|
||||
double entityDist = position.squareDistanceTo(intercept.hitVec);
|
||||
|
||||
if (dist > entityDist) {
|
||||
hitVec = intercept.hitVec;
|
||||
targetedEntity = e;
|
||||
dist = entityDist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetedEntity != null) {
|
||||
hit = new MovingObjectPosition(targetedEntity, hitVec);
|
||||
}
|
||||
}
|
||||
|
||||
if (hit == null) {
|
||||
// Use the block beneath
|
||||
y--;
|
||||
if (!worldObj.isAirBlock(x, y, z)) {
|
||||
AxisAlignedBB aabb = block.getCollisionBoundingBoxFromPool(worldObj, x, y, z);
|
||||
if (aabb != null) {
|
||||
Vec3 vec = getMiddleOfAABB(aabb);
|
||||
vec.yCoord = (aabb.maxY - y);
|
||||
hit = new MovingObjectPosition(x, y, z, ForgeDirection.UP.ordinal(), vec, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hit;
|
||||
}
|
||||
|
||||
public boolean getIsBreaking() {
|
||||
return isBreaking;
|
||||
private Vec3 getMiddleOfAABB(AxisAlignedBB aabb) {
|
||||
tempVec.xCoord = (aabb.minX + aabb.maxX) / 2f;
|
||||
tempVec.yCoord = (aabb.minY + aabb.maxY) / 2f;
|
||||
tempVec.zCoord = (aabb.minZ + aabb.maxZ) / 2f;
|
||||
return tempVec;
|
||||
}
|
||||
|
||||
public void initiateSwing() {
|
||||
swingMod = SWING_SPEED;
|
||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, TTRegistry.dynamismTablet, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveClientEvent(int par1, int par2) {
|
||||
if (par1 == 0) {
|
||||
initiateSwing();
|
||||
public boolean receiveClientEvent(int id, int type) {
|
||||
if (!worldObj.isRemote) return true;
|
||||
if (id == 0) {
|
||||
swingMod = SWING_SPEED;
|
||||
swingProgress = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -402,82 +410,86 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
swingProgress = par1NBTTagCompound.getInteger(TAG_PROGRESS);
|
||||
swingProgress = tag.getByte(TAG_PROGRESS);
|
||||
swingMod = tag.getByte(TAG_MOD);
|
||||
|
||||
readCustomNBT(par1NBTTagCompound);
|
||||
readCustomNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
|
||||
par1NBTTagCompound.setInteger(TAG_PROGRESS, swingProgress);
|
||||
par1NBTTagCompound.setInteger(TAG_MOD, swingMod);
|
||||
// par1NBTTagCompound.setString(TAG_OWNER,Owner);
|
||||
writeCustomNBT(par1NBTTagCompound);
|
||||
tag.setByte(TAG_PROGRESS, swingProgress);
|
||||
tag.setByte(TAG_MOD, swingMod);
|
||||
|
||||
writeCustomNBT(tag);
|
||||
}
|
||||
|
||||
public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
leftClick = par1NBTTagCompound.getBoolean(TAG_LEFT_CLICK);
|
||||
redstone = par1NBTTagCompound.getBoolean(TAG_REDSTONE);
|
||||
NBTTagList var2 = par1NBTTagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
inventorySlots = new ItemStack[getSizeInventory()];
|
||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
|
||||
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
|
||||
byte var5 = var4.getByte("Slot");
|
||||
if (var5 >= 0 && var5 < inventorySlots.length) inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
private void readCustomNBT(NBTTagCompound tag) {
|
||||
leftClick = tag.getBoolean(TAG_LEFT_CLICK);
|
||||
redstone = tag.getBoolean(TAG_REDSTONE);
|
||||
if (tag.hasKey("Item")) {
|
||||
NBTTagCompound itemTag = tag.getCompoundTag("Item");
|
||||
heldItem = ItemStack.loadItemStackFromNBT(itemTag);
|
||||
return;
|
||||
}
|
||||
// Legacy Compatibility (there is no reason to store it as an array)
|
||||
NBTTagList tagList = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
if (tagList.tagCount() != 0) {
|
||||
heldItem = ItemStack.loadItemStackFromNBT(tagList.getCompoundTagAt(0));
|
||||
}
|
||||
}
|
||||
|
||||
public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
par1NBTTagCompound.setBoolean(TAG_LEFT_CLICK, leftClick);
|
||||
par1NBTTagCompound.setBoolean(TAG_REDSTONE, redstone);
|
||||
NBTTagList var2 = new NBTTagList();
|
||||
for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
|
||||
if (inventorySlots[var3] != null) {
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setByte("Slot", (byte) var3);
|
||||
inventorySlots[var3].writeToNBT(var4);
|
||||
var2.appendTag(var4);
|
||||
}
|
||||
}
|
||||
par1NBTTagCompound.setTag("Items", var2);
|
||||
@Override
|
||||
public S35PacketUpdateTileEntity getDescriptionPacket() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) {
|
||||
super.onDataPacket(manager, packet);
|
||||
readCustomNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
private void writeCustomNBT(NBTTagCompound tag) {
|
||||
tag.setBoolean(TAG_LEFT_CLICK, leftClick);
|
||||
tag.setBoolean(TAG_REDSTONE, redstone);
|
||||
|
||||
tag.setTag("Item", heldItem == null ? new NBTTagCompound() : heldItem.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventorySlots.length;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return inventorySlots[i];
|
||||
return i == 0 ? heldItem : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2) {
|
||||
if (inventorySlots[par1] != null) {
|
||||
public ItemStack decrStackSize(int index, int count) {
|
||||
if (index == 0 && heldItem != null) {
|
||||
ItemStack stackAt;
|
||||
|
||||
if (inventorySlots[par1].stackSize <= par2) {
|
||||
stackAt = inventorySlots[par1];
|
||||
inventorySlots[par1] = null;
|
||||
if (heldItem.stackSize <= count) {
|
||||
stackAt = heldItem;
|
||||
heldItem = null;
|
||||
|
||||
if (!worldObj.isRemote) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
||||
return stackAt;
|
||||
} else {
|
||||
stackAt = inventorySlots[par1].splitStack(par2);
|
||||
stackAt = heldItem.splitStack(count);
|
||||
|
||||
if (inventorySlots[par1].stackSize == 0) inventorySlots[par1] = null;
|
||||
|
||||
if (!worldObj.isRemote) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
||||
return stackAt;
|
||||
if (heldItem.stackSize == 0) heldItem = null;
|
||||
}
|
||||
if (!worldObj.isRemote) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return stackAt;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -490,7 +502,8 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
inventorySlots[i] = itemstack;
|
||||
if (i != 0) return;
|
||||
heldItem = itemstack;
|
||||
|
||||
if (!worldObj.isRemote) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
@@ -527,19 +540,6 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public S35PacketUpdateTileEntity getDescriptionPacket() {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writeCustomNBT(nbttagcompound);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet) {
|
||||
super.onDataPacket(manager, packet);
|
||||
readCustomNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "tt_animationTablet";
|
||||
@@ -555,39 +555,23 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments)
|
||||
throws LuaException {
|
||||
switch (method) {
|
||||
case 0:
|
||||
return new Object[] { redstone };
|
||||
case 1:
|
||||
return setRedstoneImplementation((Boolean) arguments[0]);
|
||||
case 2:
|
||||
return new Object[] { leftClick };
|
||||
case 3:
|
||||
return setLeftClickImplementation((Boolean) arguments[0]);
|
||||
case 4:
|
||||
return new Object[] { getBlockMetadata() - 2 };
|
||||
case 5:
|
||||
return setRotationImplementation((Double) arguments[0]);
|
||||
case 6:
|
||||
return new Object[] { getStackInSlot(0) != null };
|
||||
case 7:
|
||||
return triggerImplementation();
|
||||
}
|
||||
return null;
|
||||
return switch (method) {
|
||||
case 0 -> new Object[] { redstone };
|
||||
case 1 -> setRedstoneImplementation((Boolean) arguments[0]);
|
||||
case 2 -> new Object[] { leftClick };
|
||||
case 3 -> setLeftClickImplementation((Boolean) arguments[0]);
|
||||
case 4 -> new Object[] { getBlockMetadata() - 2 };
|
||||
case 5 -> setRotationImplementation((Double) arguments[0]);
|
||||
case 6 -> new Object[] { heldItem != null };
|
||||
case 7 -> triggerImplementation();
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private Object[] triggerImplementation() {
|
||||
if (swingProgress != 0) return new Object[] { false };
|
||||
if (!isIdle()) return new Object[] { false };
|
||||
|
||||
findEntities(getTargetLoc());
|
||||
initiateSwing();
|
||||
worldObj.addBlockEvent(
|
||||
xCoord,
|
||||
yCoord,
|
||||
zCoord,
|
||||
ThaumicTinkerer.registry.getFirstBlockFromClass(BlockAnimationTablet.class),
|
||||
0,
|
||||
0);
|
||||
|
||||
return new Object[] { true };
|
||||
}
|
||||
@@ -633,12 +617,14 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public boolean prepareToMove() {
|
||||
stopBreaking();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "appliedenergistics2")
|
||||
public void doneMoving() {}
|
||||
|
||||
@Override
|
||||
@@ -648,26 +634,30 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova
|
||||
|
||||
@Callback(doc = "function():boolean -- Returns Whether tablet is redstone activated")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] getRedstone(Context context, Arguments args) throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
public Object[] getRedstone(Context context, Arguments args) {
|
||||
return new Object[] { redstone };
|
||||
}
|
||||
|
||||
@Callback(doc = "function(boolean):Nil -- Sets Whether tablet is redstone activated")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] setRedstone(Context context, Arguments args) throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
public Object[] setRedstone(Context context, Arguments args) {
|
||||
setRedstoneImplementation(args.checkBoolean(0));
|
||||
return new Object[] { redstone };
|
||||
}
|
||||
|
||||
@Callback(doc = "function():boolean -- Returns Whether tablet Left clicks")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] getLeftClick(Context context, Arguments args) throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
public Object[] getLeftClick(Context context, Arguments args) {
|
||||
return new Object[] { leftClick };
|
||||
}
|
||||
|
||||
@Callback(doc = "function(boolean):Nil -- Sets Whether tablet Left Clicks")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] setLeftClick(Context context, Arguments args) throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
public Object[] setLeftClick(Context context, Arguments args) {
|
||||
setLeftClickImplementation(args.checkBoolean(0));
|
||||
return new Object[] { leftClick };
|
||||
}
|
||||
@@ -675,26 +665,30 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova
|
||||
// TODO {"hasItem", "trigger" };
|
||||
@Callback(doc = "function():number -- Returns tablet Rotation")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] getRotation(Context context, Arguments args) throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
public Object[] getRotation(Context context, Arguments args) {
|
||||
return new Object[] { getBlockMetadata() - 2 };
|
||||
}
|
||||
|
||||
@Callback(doc = "function(number):Nil -- Sets tablet rotation")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] setRotation(Context context, Arguments args) throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
public Object[] setRotation(Context context, Arguments args) throws LuaException {
|
||||
setRotationImplementation((double) args.checkInteger(0));
|
||||
return new Object[] { getBlockMetadata() - 2 };
|
||||
}
|
||||
|
||||
@Callback(doc = "function():boolean -- Returns wether tablet has an item or not")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] hasItem(Context context, Arguments args) throws Exception {
|
||||
return new Object[] { getStackInSlot(0) != null };
|
||||
@SuppressWarnings("unused")
|
||||
public Object[] hasItem(Context context, Arguments args) {
|
||||
return new Object[] { heldItem != null };
|
||||
}
|
||||
|
||||
@Callback(doc = "function():Nil -- Triggers tablets swing")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] trigger(Context context, Arguments args) throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
public Object[] trigger(Context context, Arguments args) {
|
||||
return triggerImplementation();
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -257,35 +257,35 @@ public class TileTransvectorInterface extends TileTransvector
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHLib")
|
||||
@Optional.Method(modid = "CoFHCore")
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
TileEntity tile = getTile();
|
||||
return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).receiveEnergy(from, maxReceive, simulate) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHLib")
|
||||
@Optional.Method(modid = "CoFHCore")
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
TileEntity tile = getTile();
|
||||
return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).extractEnergy(from, maxExtract, simulate) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHLib")
|
||||
@Optional.Method(modid = "CoFHCore")
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
TileEntity tile = getTile();
|
||||
return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).getEnergyStored(from) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHLib")
|
||||
@Optional.Method(modid = "CoFHCore")
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
TileEntity tile = getTile();
|
||||
return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).getMaxEnergyStored(from) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHLib")
|
||||
@Optional.Method(modid = "CoFHCore")
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
TileEntity tile = getTile();
|
||||
return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).canConnectEnergy(from) : false;
|
||||
|
||||
@@ -208,7 +208,13 @@ public class AspectCropLootManager {
|
||||
|
||||
addAspectLoot(Aspect.ENERGY, new ItemStack(ConfigItems.itemResource, 12));
|
||||
|
||||
addAspectLoot(Aspect.MAGIC, "materialAspectShard");
|
||||
addAspectLoot(Aspect.MAGIC, new ItemStack(ConfigItems.itemShard, 1, 0));
|
||||
addAspectLoot(Aspect.MAGIC, new ItemStack(ConfigItems.itemShard, 1, 1));
|
||||
addAspectLoot(Aspect.MAGIC, new ItemStack(ConfigItems.itemShard, 1, 2));
|
||||
addAspectLoot(Aspect.MAGIC, new ItemStack(ConfigItems.itemShard, 1, 3));
|
||||
addAspectLoot(Aspect.MAGIC, new ItemStack(ConfigItems.itemShard, 1, 4));
|
||||
addAspectLoot(Aspect.MAGIC, new ItemStack(ConfigItems.itemShard, 1, 5));
|
||||
addAspectLoot(Aspect.MAGIC, new ItemStack(ConfigItems.itemShard, 1, 6));
|
||||
|
||||
addAspectLoot(Aspect.HEAL, new ItemStack(Items.golden_apple));
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package thaumic.tinkerer.common.core.helper;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import it.unimi.dsi.fastutil.Hash;
|
||||
|
||||
/*
|
||||
* Simple hashing strategy that can properly compare items
|
||||
*/
|
||||
public class ItemHashStrategy implements Hash.Strategy<ItemStack> {
|
||||
|
||||
@Override
|
||||
public int hashCode(@Nullable ItemStack key) {
|
||||
return key == null ? 0 : Objects.hash(key.getItem(), key.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable ItemStack key, @Nullable ItemStack value) {
|
||||
if (key == null || value == null) return false;
|
||||
return key.isItemEqual(value);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class ItemBloodSword extends ItemSword implements IRepairable, ITTinkerer
|
||||
|
||||
public ItemBloodSword() {
|
||||
super(EnumHelper.addToolMaterial("TT_BLOOD", 0, 950, 0, 0, ThaumcraftApi.toolMatThaumium.getEnchantability()));
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
setCreativeTab(ModCreativeTab.INSTANCE);
|
||||
}
|
||||
|
||||
@@ -112,60 +112,6 @@ public class ItemBloodSword extends ItemSword implements IRepairable, ITTinkerer
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDrops(LivingDropsEvent event) {
|
||||
if (event.source.damageType.equals("player")) {
|
||||
|
||||
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() == this
|
||||
&& stack.stackTagCompound != null
|
||||
&& stack.stackTagCompound.getInteger("Activated") == 1) {
|
||||
Aspect[] aspects = EnumMobAspect.getAspectsForEntity(event.entity);
|
||||
// ScanResult sr=new ScanResult((byte)2,0,0,event.entity,"");
|
||||
// AspectList as=ScanManager.getScanAspects(sr,event.entity.worldObj);
|
||||
// if(as!=null && as.size()!=0){
|
||||
if (aspects != null) {
|
||||
event.drops.removeAll(event.drops);
|
||||
// for(Aspect a:as.getAspects()){
|
||||
for (Aspect a : aspects) {
|
||||
addDrops(event, ItemMobAspect.getStackFromAspect(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDamageTaken(LivingAttackEvent event) {
|
||||
if (event.entity == null) return;
|
||||
|
||||
if (event.entity.worldObj.isRemote) return;
|
||||
|
||||
boolean handle = handleNext == 0;
|
||||
if (!handle) handleNext--;
|
||||
|
||||
if (event.entityLiving instanceof EntityPlayer && handle) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ItemStack itemInUse = player.itemInUse;
|
||||
if (itemInUse != null && itemInUse.getItem() == this) {
|
||||
|
||||
event.setCanceled(true);
|
||||
handleNext = 3;
|
||||
player.attackEntityFrom(DamageSource.magic, 3);
|
||||
}
|
||||
}
|
||||
|
||||
if (handle) {
|
||||
Entity source = event.source.getSourceOfDamage();
|
||||
if (source != null && source instanceof EntityLivingBase) {
|
||||
EntityLivingBase attacker = (EntityLivingBase) source;
|
||||
ItemStack itemInUse = attacker.getHeldItem();
|
||||
if (itemInUse != null && itemInUse.getItem() == this) attacker.attackEntityFrom(DamageSource.magic, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
|
||||
@@ -239,4 +185,62 @@ public class ItemBloodSword extends ItemSword implements IRepairable, ITTinkerer
|
||||
new ItemStack(Items.diamond),
|
||||
new ItemStack(Items.ghast_tear));
|
||||
}
|
||||
|
||||
public class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDrops(LivingDropsEvent event) {
|
||||
if (event.source.damageType.equals("player")) {
|
||||
|
||||
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() == ItemBloodSword.this
|
||||
&& stack.stackTagCompound != null
|
||||
&& stack.stackTagCompound.getInteger("Activated") == 1) {
|
||||
Aspect[] aspects = EnumMobAspect.getAspectsForEntity(event.entity);
|
||||
// ScanResult sr=new ScanResult((byte)2,0,0,event.entity,"");
|
||||
// AspectList as=ScanManager.getScanAspects(sr,event.entity.worldObj);
|
||||
// if(as!=null && as.size()!=0){
|
||||
if (aspects != null) {
|
||||
event.drops.removeAll(event.drops);
|
||||
// for(Aspect a:as.getAspects()){
|
||||
for (Aspect a : aspects) {
|
||||
addDrops(event, ItemMobAspect.getStackFromAspect(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDamageTaken(LivingAttackEvent event) {
|
||||
if (event.entity == null) return;
|
||||
|
||||
if (event.entity.worldObj.isRemote) return;
|
||||
|
||||
boolean handle = handleNext == 0;
|
||||
if (!handle) handleNext--;
|
||||
|
||||
if (event.entityLiving instanceof EntityPlayer && handle) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ItemStack itemInUse = player.itemInUse;
|
||||
if (itemInUse != null && itemInUse.getItem() == ItemBloodSword.this) {
|
||||
|
||||
event.setCanceled(true);
|
||||
handleNext = 3;
|
||||
player.attackEntityFrom(DamageSource.magic, 3);
|
||||
}
|
||||
}
|
||||
|
||||
if (handle) {
|
||||
Entity source = event.source.getSourceOfDamage();
|
||||
if (source != null && source instanceof EntityLivingBase) {
|
||||
EntityLivingBase attacker = (EntityLivingBase) source;
|
||||
ItemStack itemInUse = attacker.getHeldItem();
|
||||
if (itemInUse != null && itemInUse.getItem() == ItemBloodSword.this)
|
||||
attacker.attackEntityFrom(DamageSource.magic, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
/**
|
||||
* 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 @ [Nov 24, 2013, 7:31:51 PM (GMT)]
|
||||
*/
|
||||
package thaumic.tinkerer.common.item;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.ThaumcraftApi;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.research.ResearchPage;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumic.tinkerer.client.core.helper.IconHelper;
|
||||
import thaumic.tinkerer.common.core.handler.ModCreativeTab;
|
||||
import thaumic.tinkerer.common.core.helper.EnumMobAspect;
|
||||
import thaumic.tinkerer.common.lib.LibItemNames;
|
||||
import thaumic.tinkerer.common.lib.LibResearch;
|
||||
import thaumic.tinkerer.common.registry.ITTinkererItem;
|
||||
import thaumic.tinkerer.common.registry.ThaumicTinkererInfusionRecipe;
|
||||
import thaumic.tinkerer.common.registry.ThaumicTinkererRecipe;
|
||||
import thaumic.tinkerer.common.research.IRegisterableResearch;
|
||||
import thaumic.tinkerer.common.research.ResearchHelper;
|
||||
import thaumic.tinkerer.common.research.TTResearchItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ItemBloodSword extends ItemSword implements IRepairable, ITTinkererItem {
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
|
||||
|
||||
return super.getItemUseAction(par1ItemStack);
|
||||
}
|
||||
|
||||
private static final int DAMAGE = 10;
|
||||
|
||||
public ItemBloodSword() {
|
||||
super(EnumHelper.addToolMaterial("TT_BLOOD", 0, 950, 0, 0, ThaumcraftApi.toolMatThaumium.getEnchantability()));
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
setCreativeTab(ModCreativeTab.INSTANCE);
|
||||
}
|
||||
|
||||
private IIcon activeIcon;
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
|
||||
<<<<<<< HEAD
|
||||
if(stack==null)
|
||||
return itemIcon;
|
||||
if(stack.stackTagCompound==null)
|
||||
return itemIcon;
|
||||
return stack.stackTagCompound.getInteger("Activated") == 1 ? activeIcon : itemIcon;
|
||||
=======
|
||||
return (stack.stackTagCompound != null && stack.stackTagCompound.getInteger("Activated") == 1) ? activeIcon : itemIcon;
|
||||
>>>>>>> develop
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
itemIcon = IconHelper.forItem(par1IconRegister, this, 0);
|
||||
activeIcon = IconHelper.forItem(par1IconRegister, this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap getItemAttributeModifiers() {
|
||||
Multimap multimap = HashMultimap.create();
|
||||
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", DAMAGE, 0));
|
||||
multimap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", 0.25, 1));
|
||||
return multimap;
|
||||
}
|
||||
|
||||
static int handleNext = 0;
|
||||
|
||||
public void addDrops(LivingDropsEvent event, ItemStack dropStack) {
|
||||
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, dropStack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDrops(LivingDropsEvent event) {
|
||||
if (event.source.damageType.equals("player")) {
|
||||
|
||||
EntityPlayer player = (EntityPlayer) event.source.getEntity();
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() == this && stack.stackTagCompound != null && stack.stackTagCompound.getInteger("Activated") == 1) {
|
||||
Aspect[] aspects = EnumMobAspect.getAspectsForEntity(event.entity);
|
||||
//ScanResult sr=new ScanResult((byte)2,0,0,event.entity,"");
|
||||
//AspectList as=ScanManager.getScanAspects(sr,event.entity.worldObj);
|
||||
//if(as!=null && as.size()!=0){
|
||||
if (aspects != null) {
|
||||
event.drops.removeAll(event.drops);
|
||||
//for(Aspect a:as.getAspects()){
|
||||
for (Aspect a : aspects) {
|
||||
addDrops(event, ItemMobAspect.getStackFromAspect(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDamageTaken(LivingAttackEvent event) {
|
||||
if (event.entity.worldObj.isRemote)
|
||||
return;
|
||||
|
||||
boolean handle = handleNext == 0;
|
||||
if (!handle)
|
||||
handleNext--;
|
||||
|
||||
if (event.entityLiving instanceof EntityPlayer && handle) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ItemStack itemInUse = player.itemInUse;
|
||||
if (itemInUse != null && itemInUse.getItem() == this) {
|
||||
|
||||
event.setCanceled(true);
|
||||
handleNext = 3;
|
||||
player.attackEntityFrom(DamageSource.magic, 3);
|
||||
}
|
||||
}
|
||||
|
||||
if (handle) {
|
||||
Entity source = event.source.getSourceOfDamage();
|
||||
if (source != null && source instanceof EntityLivingBase) {
|
||||
EntityLivingBase attacker = (EntityLivingBase) source;
|
||||
ItemStack itemInUse = attacker.getHeldItem();
|
||||
if (itemInUse != null && itemInUse.getItem() == this)
|
||||
attacker.attackEntityFrom(DamageSource.magic, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World par2World,
|
||||
EntityPlayer par3EntityPlayer) {
|
||||
|
||||
ItemStack cache = super.onItemRightClick(stack, par2World, par3EntityPlayer);
|
||||
if (par3EntityPlayer.isSneaking() && !par2World.isRemote) {
|
||||
if (stack.stackTagCompound == null) {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
if (stack.stackTagCompound.getInteger("Activated") == 0) {
|
||||
par3EntityPlayer.addChatMessage(new ChatComponentTranslation("ttmisc.bloodSword.activateEssentiaHarvest"));
|
||||
stack.stackTagCompound.setInteger("Activated", 1);
|
||||
} else {
|
||||
par3EntityPlayer.addChatMessage(new ChatComponentTranslation("ttmisc.bloodSword.deactivateEssentiaHarvest"));
|
||||
stack.stackTagCompound.setInteger("Activated", 0);
|
||||
}
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Object> getSpecialParameters() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemName() {
|
||||
return LibItemNames.BLOOD_SWORD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRegister() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplayInTab() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRegisterableResearch getResearchItem() {
|
||||
return (TTResearchItem) new TTResearchItem(LibResearch.KEY_BLOOD_SWORD, new AspectList().add(Aspect.HUNGER, 2).add(Aspect.WEAPON, 1).add(Aspect.FLESH, 1).add(Aspect.SOUL, 1), -4, 6, 3, new ItemStack(this)).setParents(LibResearch.KEY_CLEANSING_TALISMAN)
|
||||
.setPages(new ResearchPage("0"), ResearchHelper.infusionPage(LibResearch.KEY_BLOOD_SWORD), new ResearchPage("1")).setSecondary();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThaumicTinkererRecipe getRecipeItem() {
|
||||
return new ThaumicTinkererInfusionRecipe(LibResearch.KEY_BLOOD_SWORD, new ItemStack(this), 6, new AspectList().add(Aspect.HUNGER, 20).add(Aspect.DARKNESS, 5).add(Aspect.SOUL, 10).add(Aspect.MAN, 6), new ItemStack(ConfigItems.itemSwordThaumium),
|
||||
new ItemStack(Items.rotten_flesh), new ItemStack(Items.porkchop), new ItemStack(Items.beef), new ItemStack(Items.bone), new ItemStack(Items.diamond), new ItemStack(Items.ghast_tear));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import thaumic.tinkerer.common.research.IRegisterableResearch;
|
||||
import thaumic.tinkerer.common.research.ResearchHelper;
|
||||
import thaumic.tinkerer.common.research.TTResearchItem;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.common.entity.EntityMagicMissile;
|
||||
|
||||
public class ItemFocusDeflect extends ItemModFocus {
|
||||
|
||||
@@ -87,6 +88,15 @@ public class ItemFocusDeflect extends ItemModFocus {
|
||||
e.posX += motionVec.x;
|
||||
e.posY += motionVec.y;
|
||||
e.posZ += motionVec.z;
|
||||
|
||||
checkBotaniaMagicMissile(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkBotaniaMagicMissile(Entity e) {
|
||||
if (!Loader.isModLoaded("Botania")) return;
|
||||
if (e instanceof EntityMagicMissile) {
|
||||
e.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ItemFocusDislocation extends ItemModFocus {
|
||||
stack.getItemDamage(),
|
||||
1 | 2);
|
||||
((ItemBlock) stack.getItem()).field_150939_a
|
||||
.onBlockPlacedBy(world, mop.blockX, mop.blockY, mop.blockZ, player, itemstack);
|
||||
.onBlockPlacedBy(world, mop.blockX, mop.blockY, mop.blockZ, player, stack);
|
||||
NBTTagCompound tileCmp = getStackTileEntity(itemstack);
|
||||
if (tileCmp != null && !tileCmp.hasNoTags()) {
|
||||
TileEntity tile1 = TileEntity.createAndLoadEntity(tileCmp);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
package thaumic.tinkerer.common.item.kami;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -27,6 +28,10 @@ import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.api.expanded.BaubleItemHelper;
|
||||
import baubles.api.expanded.IBaubleExpanded;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
@@ -50,7 +55,10 @@ import thaumic.tinkerer.common.research.IRegisterableResearch;
|
||||
import thaumic.tinkerer.common.research.KamiResearchItem;
|
||||
import thaumic.tinkerer.common.research.ResearchHelper;
|
||||
|
||||
public class ItemIchorPouch extends ItemFocusPouch implements IBauble, ITTinkererItem {
|
||||
@Optional.Interface(iface = "baubles.api.expanded.IBaubleExpanded", modid = "Baubles|Expanded")
|
||||
public class ItemIchorPouch extends ItemFocusPouch implements IBauble, IBaubleExpanded, ITTinkererItem {
|
||||
|
||||
private static final boolean baublesExpandedLoaded = Loader.isModLoaded("Baubles|Expanded");
|
||||
|
||||
public ItemIchorPouch() {
|
||||
super();
|
||||
@@ -75,23 +83,38 @@ public class ItemIchorPouch extends ItemFocusPouch implements IBauble, ITTinkere
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
par3EntityPlayer.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_ICHOR_POUCH, par2World, 0, 0, 0);
|
||||
if (!par2World.isRemote)
|
||||
par3EntityPlayer.openGui(ThaumicTinkerer.instance, LibGuiIDs.GUI_ID_ICHOR_POUCH, par2World, 0, 0, 0);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInventory(ItemStack item) {
|
||||
ItemStack[] stackList = new ItemStack[13 * 9];
|
||||
if (item.hasTagCompound()) {
|
||||
NBTTagList var2 = item.stackTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
|
||||
for (int var3 = 0; var3 < var2.tagCount(); var3++) {
|
||||
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
|
||||
int var5 = var4.getByte("Slot") & 0xFF;
|
||||
if (var5 >= 0 && var5 < stackList.length) stackList[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
ItemStack[] inventory = new ItemStack[13 * 9];
|
||||
if (!item.hasTagCompound()) {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
NBTTagList tagList = item.stackTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound tag = tagList.getCompoundTagAt(i);
|
||||
int slot = tag.getByte("Slot") & 0xFF;
|
||||
|
||||
if (slot < inventory.length) {
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(tag);
|
||||
}
|
||||
}
|
||||
|
||||
return stackList;
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List textLines, boolean showAdvancedInfo) {
|
||||
if (baublesExpandedLoaded) {
|
||||
BaubleItemHelper.addSlotInformation(textLines, getBaubleTypes(null));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,6 +122,12 @@ public class ItemIchorPouch extends ItemFocusPouch implements IBauble, ITTinkere
|
||||
return BaubleType.BELT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles|Expanded")
|
||||
public String[] getBaubleTypes(ItemStack itemstack) {
|
||||
return new String[] { "belt", "focus_pouch" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,50 +49,6 @@ public class ItemProtoclay extends ItemKamiBase {
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void Interact(PlayerInteractEvent event) {
|
||||
if (event.entityPlayer.inventory.hasItem(ThaumicTinkerer.registry.getFirstItemFromClass(ItemProtoclay.class))) {
|
||||
World par2World = event.world;
|
||||
Entity par3Entity = event.entityPlayer;
|
||||
EntityPlayer player = (EntityPlayer) par3Entity;
|
||||
ItemStack currentStack = player.getCurrentEquippedItem();
|
||||
if (currentStack == null || !(currentStack.getItem() instanceof IAdvancedTool)) return;
|
||||
IAdvancedTool tool = (IAdvancedTool) currentStack.getItem();
|
||||
|
||||
if (tool.getType().equals("sword")) return;
|
||||
|
||||
MovingObjectPosition pos = ToolHandler.raytraceFromEntity(par2World, par3Entity, true, 4.5F);
|
||||
String typeToFind = "";
|
||||
|
||||
if (player.isSwingInProgress && pos != null) {
|
||||
Block block = par2World.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
|
||||
if (block != null) {
|
||||
Material mat = block.getMaterial();
|
||||
if (ToolHandler.isRightMaterial(mat, ToolHandler.materialsPick)) typeToFind = "pick";
|
||||
else if (ToolHandler.isRightMaterial(mat, ToolHandler.materialsShovel)) typeToFind = "shovel";
|
||||
else if (ToolHandler.isRightMaterial(mat, ToolHandler.materialsAxe)) typeToFind = "axe";
|
||||
}
|
||||
}
|
||||
|
||||
if (tool.getType().equals(typeToFind) || typeToFind.isEmpty()) return;
|
||||
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
|
||||
if (stackInSlot != null && stackInSlot.getItem() instanceof IAdvancedTool
|
||||
&& stackInSlot != currentStack) {
|
||||
IAdvancedTool toolInSlot = (IAdvancedTool) stackInSlot.getItem();
|
||||
if (toolInSlot.getType().equals(typeToFind)) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, stackInSlot);
|
||||
player.inventory.setInventorySlotContents(i, currentStack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {}
|
||||
|
||||
@@ -136,7 +92,56 @@ public class ItemProtoclay extends ItemKamiBase {
|
||||
|
||||
@Override
|
||||
public boolean shouldRegister() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
return super.shouldRegister();
|
||||
}
|
||||
|
||||
public class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void Interact(PlayerInteractEvent event) {
|
||||
if (event.entityPlayer.inventory
|
||||
.hasItem(ThaumicTinkerer.registry.getFirstItemFromClass(ItemProtoclay.class))) {
|
||||
World par2World = event.world;
|
||||
Entity par3Entity = event.entityPlayer;
|
||||
EntityPlayer player = (EntityPlayer) par3Entity;
|
||||
ItemStack currentStack = player.getCurrentEquippedItem();
|
||||
if (currentStack == null || !(currentStack.getItem() instanceof IAdvancedTool)) return;
|
||||
IAdvancedTool tool = (IAdvancedTool) currentStack.getItem();
|
||||
|
||||
if (tool.getType().equals("sword")) return;
|
||||
|
||||
MovingObjectPosition pos = ToolHandler.raytraceFromEntity(par2World, par3Entity, true, 4.5F);
|
||||
String typeToFind = "";
|
||||
|
||||
if (player.isSwingInProgress && pos != null) {
|
||||
Block block = par2World.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
|
||||
if (block != null) {
|
||||
Material mat = block.getMaterial();
|
||||
if (ToolHandler.isRightMaterial(mat, ToolHandler.materialsPick)) typeToFind = "pick";
|
||||
else if (ToolHandler.isRightMaterial(mat, ToolHandler.materialsShovel)) typeToFind = "shovel";
|
||||
else if (ToolHandler.isRightMaterial(mat, ToolHandler.materialsAxe)) typeToFind = "axe";
|
||||
}
|
||||
}
|
||||
|
||||
if (tool.getType().equals(typeToFind) || typeToFind.isEmpty()) return;
|
||||
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
|
||||
if (stackInSlot != null && stackInSlot.getItem() instanceof IAdvancedTool
|
||||
&& stackInSlot != currentStack) {
|
||||
IAdvancedTool toolInSlot = (IAdvancedTool) stackInSlot.getItem();
|
||||
if (toolInSlot.getType().equals(typeToFind)) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, stackInSlot);
|
||||
player.inventory.setInventorySlotContents(i, currentStack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,15 +20,21 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.research.ResearchPage;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumic.tinkerer.common.ThaumicTinkerer;
|
||||
@@ -41,8 +47,12 @@ import thaumic.tinkerer.common.registry.ThaumicTinkererRecipe;
|
||||
import thaumic.tinkerer.common.research.IRegisterableResearch;
|
||||
import thaumic.tinkerer.common.research.KamiResearchItem;
|
||||
import thaumic.tinkerer.common.research.ResearchHelper;
|
||||
import thaumicboots.api.IBoots;
|
||||
|
||||
public class ItemGemBoots extends ItemIchorclothArmorAdv {
|
||||
@Interface(iface = "thaumicboots.api.IBoots", modid = "thaumicboots")
|
||||
public class ItemGemBoots extends ItemIchorclothArmorAdv implements IBoots {
|
||||
|
||||
public float speedBonus = 0.075F;
|
||||
|
||||
public static List<String> playersWith1Step = new ArrayList<>();
|
||||
|
||||
@@ -63,14 +73,14 @@ public class ItemGemBoots extends ItemIchorclothArmorAdv {
|
||||
|
||||
if (player.worldObj.isRemote) player.stepHeight = player.isSneaking() ? 0.5F : 1F;
|
||||
if ((player.onGround || player.capabilities.isFlying) && player.moveForward > 0F)
|
||||
player.moveFlying(0F, 1F, player.capabilities.isFlying ? 0.075F : 0.15F);
|
||||
player.moveFlying(0F, speedBonus, player.capabilities.isFlying ? 0.075F : 0.15F);
|
||||
player.jumpMovementFactor = player.isSprinting() ? 0.05F : 0.04F;
|
||||
player.fallDistance = 0F;
|
||||
|
||||
if (ConfigHandler.shouldKamiBootsDoGrass) {
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY - 1;
|
||||
int z = (int) player.posZ;
|
||||
int x = MathHelper.floor_double(player.posX);
|
||||
int y = MathHelper.floor_double(player.posY) - 1;
|
||||
int z = MathHelper.floor_double(player.posZ);
|
||||
if (player.worldObj.getBlock(x, y, z) == Blocks.dirt && player.worldObj.getBlockMetadata(x, y, z) == 0)
|
||||
player.worldObj.setBlock(x, y, z, Blocks.grass, 0, 2);
|
||||
}
|
||||
@@ -120,47 +130,143 @@ public class ItemGemBoots extends ItemIchorclothArmorAdv {
|
||||
new ItemStack(Items.lead));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerJump(LivingJumpEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
boolean hasArmor = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem() == this;
|
||||
|
||||
if (hasArmor && ThaumicTinkerer.proxy.armorStatus(player) && player.getCurrentArmor(0).getItemDamage() == 0)
|
||||
player.motionY += 0.3;
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
|
||||
if (getIntertialState(itemStack) && player.moveForward == 0
|
||||
&& player.moveStrafing == 0
|
||||
&& player.capabilities.isFlying) {
|
||||
player.motionX *= 0.5;
|
||||
player.motionZ *= 0.5;
|
||||
}
|
||||
}
|
||||
boolean omniMode = false;
|
||||
if (ThaumicTinkerer.isBootsActive) {
|
||||
omniMode = isOmniEnabled(itemStack);
|
||||
if ((player.moveForward == 0F && player.moveStrafing == 0F && omniMode)
|
||||
|| (player.moveForward <= 0F && !omniMode)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (player.moveForward != 0.0F || player.moveStrafing != 0.0F) {
|
||||
if (player.worldObj.isRemote && !player.isSneaking()) {
|
||||
if (!Thaumcraft.instance.entityEventHandler.prevStep.containsKey(player.getEntityId())) {
|
||||
Thaumcraft.instance.entityEventHandler.prevStep.put(player.getEntityId(), player.stepHeight);
|
||||
}
|
||||
player.stepHeight = 1.0F;
|
||||
}
|
||||
float speedMod = (float) getSpeedModifier(itemStack);
|
||||
if (player.onGround || player.isOnLadder() || player.capabilities.isFlying) {
|
||||
float bonus = speedBonus;
|
||||
if (player.isInWater()) {
|
||||
bonus /= 4.0F;
|
||||
}
|
||||
|
||||
// Attempt at fixing a bug with falling on SMP
|
||||
// In theory, this should be redundant
|
||||
@SubscribeEvent
|
||||
public void onFall(LivingFallEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
boolean hasArmor = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem() == this;
|
||||
if (hasArmor) {
|
||||
event.distance = 0;
|
||||
if (player.isSneaking()) {
|
||||
bonus /= 2.0F;
|
||||
}
|
||||
bonus *= speedMod;
|
||||
if (ThaumicTinkerer.isBootsActive) {
|
||||
applyOmniState(player, bonus, itemStack);
|
||||
} else if (player.moveForward > 0.0) {
|
||||
player.moveFlying(0.0F, player.moveForward, bonus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onLivingUpdate(LivingUpdateEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer && event.entityLiving.worldObj.isRemote) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
@Optional.Method(modid = "thaumicboots")
|
||||
public void applyOmniState(EntityPlayer player, float bonus, ItemStack itemStack) {
|
||||
if (player.moveForward != 0.0) {
|
||||
player.moveFlying(0.0F, player.moveForward, bonus);
|
||||
}
|
||||
if (player.moveStrafing != 0.0 && getOmniState(itemStack)) {
|
||||
player.moveFlying(player.moveStrafing, 0.0F, bonus);
|
||||
}
|
||||
}
|
||||
|
||||
boolean highStepListed = playersWith1Step.contains(player.getGameProfile().getName());
|
||||
boolean hasHighStep = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem() == this;
|
||||
// Avoid NSM Exception when ThaumicBoots is not present.
|
||||
public double getSpeedModifier(ItemStack stack) {
|
||||
if (stack.stackTagCompound != null) {
|
||||
return stack.stackTagCompound.getDouble("speed");
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
if (!highStepListed && (hasHighStep && ThaumicTinkerer.proxy.armorStatus(player)
|
||||
&& player.getCurrentArmor(0).getItemDamage() == 0))
|
||||
playersWith1Step.add(player.getGameProfile().getName());
|
||||
public double getJumpModifier(ItemStack stack) {
|
||||
if (stack.stackTagCompound != null) {
|
||||
return stack.stackTagCompound.getDouble("jump");
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
if ((!hasHighStep || !ThaumicTinkerer.proxy.armorStatus(player)
|
||||
|| player.getCurrentArmor(0).getItemDamage() == 1) && highStepListed) {
|
||||
playersWith1Step.remove(player.getGameProfile().getName());
|
||||
player.stepHeight = 0.5F;
|
||||
public boolean getOmniState(ItemStack stack) {
|
||||
if (stack.stackTagCompound != null) {
|
||||
return stack.stackTagCompound.getBoolean("omni");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getIntertialState(ItemStack stack) {
|
||||
if (stack.stackTagCompound != null) {
|
||||
return stack.stackTagCompound.getBoolean("inertiacanceling");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvents() {
|
||||
super.registerEvents();
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
|
||||
public class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerJump(LivingJumpEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ItemStack boots = player.getCurrentArmor(0);
|
||||
boolean hasArmor = player.getCurrentArmor(0) != null
|
||||
&& player.getCurrentArmor(0).getItem() == ItemGemBoots.this;
|
||||
|
||||
if (hasArmor && ThaumicTinkerer.proxy.armorStatus(player)
|
||||
&& player.getCurrentArmor(0).getItemDamage() == 0)
|
||||
player.motionY += 0.3 * (float) getJumpModifier(boots);;
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt at fixing a bug with falling on SMP
|
||||
// In theory, this should be redundant
|
||||
@SubscribeEvent
|
||||
public void onFall(LivingFallEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
boolean hasArmor = player.getCurrentArmor(0) != null
|
||||
&& player.getCurrentArmor(0).getItem() == ItemGemBoots.this;
|
||||
if (hasArmor) {
|
||||
event.distance = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onLivingUpdate(LivingUpdateEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer && event.entityLiving.worldObj.isRemote) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
|
||||
boolean highStepListed = playersWith1Step.contains(player.getGameProfile().getName());
|
||||
boolean hasHighStep = player.getCurrentArmor(0) != null
|
||||
&& player.getCurrentArmor(0).getItem() == ItemGemBoots.this;
|
||||
|
||||
if (!highStepListed && (hasHighStep && ThaumicTinkerer.proxy.armorStatus(player)
|
||||
&& player.getCurrentArmor(0).getItemDamage() == 0))
|
||||
playersWith1Step.add(player.getGameProfile().getName());
|
||||
|
||||
if ((!hasHighStep || !ThaumicTinkerer.proxy.armorStatus(player)
|
||||
|| player.getCurrentArmor(0).getItemDamage() == 1) && highStepListed) {
|
||||
playersWith1Step.remove(player.getGameProfile().getName());
|
||||
player.stepHeight = 0.5F;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -128,27 +129,36 @@ public class ItemGemChest extends ItemIchorclothArmorAdv {
|
||||
new ItemStack(Items.arrow));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void updatePlayerFlyStatus(LivingUpdateEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
@Override
|
||||
public void registerEvents() {
|
||||
super.registerEvents();
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
|
||||
ItemStack armor = player.getCurrentArmor(3 - armorType);
|
||||
if (armor != null && armor.getItem() == this) tickPlayer(player);
|
||||
public class EventHandler {
|
||||
|
||||
if (playersWithFlight.contains(playerStr(player))) {
|
||||
if (shouldPlayerHaveFlight(player)) player.capabilities.allowFlying = true;
|
||||
else {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
player.capabilities.allowFlying = false;
|
||||
player.capabilities.isFlying = false;
|
||||
player.capabilities.disableDamage = false;
|
||||
@SubscribeEvent
|
||||
public void updatePlayerFlyStatus(LivingUpdateEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
|
||||
ItemStack armor = player.getCurrentArmor(3 - armorType);
|
||||
if (armor != null && armor.getItem() == ItemGemChest.this) tickPlayer(player);
|
||||
|
||||
if (playersWithFlight.contains(playerStr(player))) {
|
||||
if (shouldPlayerHaveFlight(player)) player.capabilities.allowFlying = true;
|
||||
else {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
player.capabilities.allowFlying = false;
|
||||
player.capabilities.isFlying = false;
|
||||
player.capabilities.disableDamage = false;
|
||||
}
|
||||
playersWithFlight.remove(playerStr(player));
|
||||
}
|
||||
playersWithFlight.remove(playerStr(player));
|
||||
} else if (shouldPlayerHaveFlight(player)) {
|
||||
playersWithFlight.add(playerStr(player));
|
||||
player.capabilities.allowFlying = true;
|
||||
}
|
||||
} else if (shouldPlayerHaveFlight(player)) {
|
||||
playersWithFlight.add(playerStr(player));
|
||||
player.capabilities.allowFlying = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,19 +22,23 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import gregtech.api.hazards.Hazard;
|
||||
import gregtech.api.hazards.IHazardProtector;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumic.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
|
||||
import thaumic.tinkerer.client.lib.LibResources;
|
||||
import thaumic.tinkerer.common.registry.ThaumicTinkererRecipe;
|
||||
import thaumic.tinkerer.common.research.IRegisterableResearch;
|
||||
|
||||
public abstract class ItemIchorclothArmorAdv extends ItemIchorclothArmor {
|
||||
@Optional.InterfaceList({ @Optional.Interface(iface = "gregtech.api.hazards.IHazardProtector", modid = "gregtech_nh") })
|
||||
public abstract class ItemIchorclothArmorAdv extends ItemIchorclothArmor implements IHazardProtector {
|
||||
|
||||
public ItemIchorclothArmorAdv(int par2) {
|
||||
super(par2);
|
||||
setHasSubtypes(true);
|
||||
if (ticks()) MinecraftForge.EVENT_BUS.register(this);
|
||||
registerEvents();
|
||||
}
|
||||
|
||||
public ItemIchorclothArmorAdv() {
|
||||
@@ -82,16 +86,6 @@ public abstract class ItemIchorclothArmorAdv extends ItemIchorclothArmor {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityUpdate(LivingUpdateEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
|
||||
ItemStack armor = player.getCurrentArmor(3 - armorType);
|
||||
if (armor != null && armor.getItem() == this) tickPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
void tickPlayer(EntityPlayer player) {
|
||||
// NO-OP
|
||||
}
|
||||
@@ -108,4 +102,28 @@ public abstract class ItemIchorclothArmorAdv extends ItemIchorclothArmor {
|
||||
public ThaumicTinkererRecipe getRecipeItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// GT5 Hazmat protection
|
||||
@Optional.Method(modid = "gregtech_nh")
|
||||
@Override
|
||||
public boolean protectsAgainst(ItemStack itemStack, Hazard hazard) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void registerEvents() {
|
||||
if (ticks()) MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
|
||||
public class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityUpdate(LivingUpdateEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
|
||||
ItemStack armor = player.getCurrentArmor(3 - armorType);
|
||||
if (armor != null && armor.getItem() == ItemIchorclothArmorAdv.this) tickPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,5 +37,4 @@ public final class LibBlockIDs {
|
||||
public static int idSpawner = 2633;
|
||||
public static int idPortal = 2816;
|
||||
public static int idGolemConnector = 2817;
|
||||
public static int idVisweaver = 2818;
|
||||
}
|
||||
@@ -68,6 +68,4 @@ public final class LibBlockNames {
|
||||
public static final String INFUSED_GRAIN_BLOCK = INFUSED_GRAIN_BASE + "Block";
|
||||
|
||||
public static final String FORCEFIELD = "forcefield";
|
||||
|
||||
public static final String VISWEAVER = "visweaver";
|
||||
}
|
||||
@@ -22,5 +22,4 @@ public final class LibGuiIDs {
|
||||
public static final int GUI_ID_ICHOR_POUCH = 50;
|
||||
public static final int GUI_ID_WARP_GATE = 51;
|
||||
public static final int GUI_ID_WARP_GATE_DESTINATIONS = 52;
|
||||
public static final int GUI_ID_VISWEAVER = 53;
|
||||
}
|
||||
@@ -41,7 +41,6 @@ public final class LibResearch {
|
||||
public static final String KEY_ENCHANT_DESINTEGRATE = "TTENCH_DESINTEGRATE";
|
||||
public static final String KEY_ENCHANT_QUICK_DRAW = "TTENCH_QUICK_DRAW";
|
||||
public static final String KEY_ENCHANT_VAMPIRISM = "TTENCH_VAMPIRISM";
|
||||
public static final String KEY_VISWEAVER = "VISWEAVER";
|
||||
|
||||
public static final String KEY_ENCHANT_DISPERSED_STRIKE = "TTENCH_DISPERSED";
|
||||
public static final String KEY_ENCHANT_FINAL_STRIKE = "TTENCH_FINAL";
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import thaumic.tinkerer.client.gui.GUIVisweaver;
|
||||
import thaumic.tinkerer.client.gui.GuiAnimationTablet;
|
||||
import thaumic.tinkerer.client.gui.GuiAspectAnalyzer;
|
||||
import thaumic.tinkerer.client.gui.GuiEnchanting;
|
||||
@@ -29,13 +28,11 @@ import thaumic.tinkerer.common.block.tile.TileAspectAnalyzer;
|
||||
import thaumic.tinkerer.common.block.tile.TileEnchanter;
|
||||
import thaumic.tinkerer.common.block.tile.TileMobMagnet;
|
||||
import thaumic.tinkerer.common.block.tile.TileRPlacer;
|
||||
import thaumic.tinkerer.common.block.tile.TileVisweaver;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerAnimationTablet;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerAspectAnalyzer;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerEnchanter;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerMobMagnet;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerRemotePlacer;
|
||||
import thaumic.tinkerer.common.block.tile.container.ContainerVisweaver;
|
||||
import thaumic.tinkerer.common.block.tile.container.kami.ContainerIchorPouch;
|
||||
import thaumic.tinkerer.common.block.tile.container.kami.ContainerWarpGate;
|
||||
import thaumic.tinkerer.common.block.tile.kami.TileWarpGate;
|
||||
@@ -61,12 +58,9 @@ public class GuiHandler implements IGuiHandler {
|
||||
case LibGuiIDs.GUI_ID_ASPECT_ANALYZER:
|
||||
return new ContainerAspectAnalyzer((TileAspectAnalyzer) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_VISWEAVER:
|
||||
return new ContainerVisweaver((TileVisweaver) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_ICHOR_POUCH:
|
||||
if (!isDimensionAllowed(player)) return null;
|
||||
return new ContainerIchorPouch(player);
|
||||
return new ContainerIchorPouch(player, player.getCurrentEquippedItem());
|
||||
|
||||
case LibGuiIDs.GUI_ID_WARP_GATE:
|
||||
return new ContainerWarpGate((TileWarpGate) tile, player.inventory);
|
||||
@@ -92,12 +86,9 @@ public class GuiHandler implements IGuiHandler {
|
||||
case LibGuiIDs.GUI_ID_ASPECT_ANALYZER:
|
||||
return new GuiAspectAnalyzer((TileAspectAnalyzer) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_VISWEAVER:
|
||||
return new GUIVisweaver((TileVisweaver) tile, player.inventory);
|
||||
|
||||
case LibGuiIDs.GUI_ID_ICHOR_POUCH:
|
||||
if (!isDimensionAllowed(player)) return null;
|
||||
return new GuiIchorPouch(new ContainerIchorPouch(player));
|
||||
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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,7 @@ item.mobAspect.name=Soul Aspect
|
||||
item.mobAspect.condensed.name=Condensed Soul Aspect
|
||||
item.mobAspect.infused.name=Infused Soul Aspect
|
||||
item.infusedSeeds.name=Infused Seeds
|
||||
item.infusedPotion.name=Potion
|
||||
item.infusedPotion.Aer.name=Potion of Aer
|
||||
item.infusedPotion.Ignis.name=Potion of Ignis
|
||||
item.infusedPotion.Terra.name=Potion of Terra
|
||||
@@ -152,7 +153,12 @@ tile.travelSlab.name=Paving Slab of Travel
|
||||
tile.travelSlabFull.name=Paving Slab of Travel
|
||||
tile.travelStairs.name=Paving Stair of Travel
|
||||
tile.wardSlab.name=Paving Slab of Warding
|
||||
tile.wardSlabFull.name=Paving Slab of Warding
|
||||
tile.infusedFarmland.name=Infused Farmland
|
||||
tile.gaseousLight.name=Gaseous Light
|
||||
tile.gaseousShadow.name=Gaseous Shadow
|
||||
tile.infusedGrainBlock.name=Imbued Grain
|
||||
tile.nitorGas.name=Nitor Gas
|
||||
|
||||
# Fire
|
||||
tile.fireWater.name=Aqua Imbued Fire
|
||||
@@ -180,7 +186,6 @@ tile.Levitational Locomotive.name=Levitational Locomotive
|
||||
tile.Levitational Locomotive Relay.name=Levitational Locomotive Relay
|
||||
tile.golemConnector.name=Golem Connector
|
||||
tile.remotePlacer.name=Remote Placer
|
||||
tile.visweaver.name=Visweaver
|
||||
|
||||
# KAMI BLOCK NAMES
|
||||
tile.warpGate.name=Celestial Gateway
|
||||
@@ -552,7 +557,7 @@ ttresearch.page.ICHOR_SWORD_GEM.1=Soul Hearts are hearts that can only be used o
|
||||
# -- BOTTOMLESS POUCH
|
||||
ttresearch.name.ICHOR_POUCH=Bottomless Pouch
|
||||
ttresearch.lore.ICHOR_POUCH=Try not to tear it
|
||||
ttresearch.page.ICHOR_POUCH.0=By infusing a Focus Pouch with items such as the Portable Hole focus, you managed to allow it to not only store more than Foci, but also to have a very extensive storage space.<BR><BR>This pouch can not only carry more than four chests, but it also doubles as a standard Focus Pouch, allowing any foci within it to be inserted in a wand like normally. You can kiss your inventory problems goodbye.
|
||||
ttresearch.page.ICHOR_POUCH.0=By infusing a Focus Pouch with items such as the Portable Hole focus, you’ve enhanced it to store not just foci, but any kind of items with an impressively spacious interior.<BR><BR>This upgraded pouch can hold the contents of more than four chests, all while functioning as a regular Focus Pouch, allowing any foci inside to be equipped to a wand as usual. You can kiss your inventory problems goodbye.
|
||||
|
||||
# -- BLACK HOLE RING
|
||||
ttresearch.name.BLOCK_TALISMAN=Black Hole Ring
|
||||
@@ -624,11 +629,6 @@ ttresearch.page.INFUSED_POTIONS.3=There are two ways to give crops primal tenden
|
||||
ttresearch.page.INFUSED_POTIONS.4=Crops will also drain tendencies from nearby crops. A crop will drain points from an adjacent crop with an equal or greater number of points.
|
||||
ttresearch.page.INFUSED_POTIONS.5=Some plants will create special grain, which can be made into potions. <BR> Earth infused potions summons barriers between mobs that attack you. <BR> Fire infused potions trap your enemies in a sphere of fire. <BR> Air infused potions send your enemies up in the air. <BR> Water infused potions chill surrounding lava.
|
||||
|
||||
# -- VISWEAVER
|
||||
ttresearch.name.VISWEAVER=Visweaver
|
||||
ttresearch.lore.VISWEAVER=Transmutation through vis
|
||||
ttresearch.page.VISWEAVER.0=Some objects in this world can be altered to different states purely by nudging the balance of primal essentia, it seems. You've designed a device to do just that by infusing large amounts of centivis into items.
|
||||
|
||||
# -- WAILA
|
||||
ttwaila.nothing=Nothing
|
||||
ttwaila.currentTool=Current Tool: %s
|
||||
|
||||
@@ -411,7 +411,7 @@ ttresearch.lore.FOCUS_HEAL=Pansements etc.
|
||||
ttresearch.page.FOCUS_HEAL.0=You know Pech carry powerful foci that can induce diseases, with that, you devised a way to use them to your benefits.<BR><BR>This focus will slowly mend the caster's wounds as they're using it, using vis from the wand in the process.
|
||||
|
||||
# -- WAND FOCUS: ENDER RIFT
|
||||
ttresearch.name.FOCUS_ENDER_Foci de baguette: Crevasse du Néant
|
||||
ttresearch.name.FOCUS_ENDER_CHEST=Foci de baguette: Crevasse du Néant
|
||||
ttresearch.lore.FOCUS_ENDER_CHEST=Une poche de la quatrième dimension
|
||||
ttresearch.page.FOCUS_ENDER_CHEST.0=By combining a Hand Mirror with a portable hole, you managed to construct a focus that tears a rift in the ender, allowing you to access the contents of your Ender Chest remotely.
|
||||
ttresearch.page.FOCUS_ENDER_CHEST.ES=By combining a Hand Mirror with a portable hole, you managed to construct a focus that tears a rift in the ender, allowing you to access the contents of your Ender Chests remotely. <BR> Shift right click on an ender chest to set the focus to that colour, or shift right click on a block of obsidian to set the focus to the vanilla ender storage.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
Reference in new issue
Block a user