Jump to content

DrLogiq

Members
  • Posts

    14
  • Joined

  • Last visited

Converted

  • Personal Text
    "I reject your reality and substitute my own"
    - Adam Savage

Recent Profile Visitors

1076 profile views

DrLogiq's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. Did you get this to work? I'm having problems with models from MrCrayfish's model maker and orientation too, in 1.11.2 however, still relevant. I've had success with another block, but for some reason it crashes when trying to do this with a model. I have a machine which is just like the furnace - a block with different side textures, and this will place in one of 4 horizontal directions, but my other machine which uses a model gives this: I'm using the same parent. And I know the model and block file are good because they were working just fine before I added the FACING code.
  2. Ah thank you Jay, I will try that now. Edit: Works like an absolute treat! Thank you, you're a legend. That's the 7x7 crafting station complete, now just to make the TileEntity store the contents of the craftmatrix when you close the GUI and restore it when you open, so it stores its contents like the Tinker's construct one does, because let's face it... crafting is so much easier when you can leave things in the crafting bench
  3. I fixed the problem... strangely enough the GUI wasn't opening because of a botched crafting recipe. I mean, there was nothing wrong with the formatting of the recipe, and all the items and blocks needed were surely initialized and registered etc before the recipe was registered (because it registers them the first time you click the station (IDK why, but it works so I'll leave it for now)) Strange stuff. I wish this could all be written in one of the C languages, makes SO much more sense Regardless though, I now have to face the dreaded problem of shift-clicking the crafting result, only to get all the remaining items in the crafting matrix area cranking their stack size to over 9000... like, literally. I don't want to have to disable shift-clicking recipes. I was using an old 1.7 tutorial for some of this, and altering Minecraft's "Workbench" code for the rest. But I don't know where to even start looking for this weird bug. I don't even think it gives me the right amount of items either. It's fine when you remove the resulting item manually without holding shift. It should give 5 per craft (these will be slightly more expensive recipes, eventually... so it seems only fair to give a few machines out of it ) I suspect it has something to do with the getRemainingItems() function in the crafting manager Here's some of the codes: Container public class ContainerStation extends Container { private World worldRef; private TileEntityStation tileEntityRef; public InventoryCrafting craftMatrix; public IInventory craftResult; private IItemHandler handler; public ContainerStation(EntityPlayer player, TileEntityStation te, World worldReference) { this.tileEntityRef = te; this.tileEntityRef.container = this; this.worldRef = worldReference; this.handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); this.craftMatrix = new InventoryCrafting(this, 7, 7); this.craftResult = new InventoryCraftResult(); // Output slot this.addSlotToContainer(new SlotCrafting(player, this.craftMatrix, this.craftResult, 0, 152, 74)); // Crafting Slots int xStart = 8; int yStart = 20; // Row 1 this.addSlotToContainer(new Slot(this.craftMatrix, 0, xStart, yStart)); this.addSlotToContainer(new Slot(this.craftMatrix, 1, xStart + 18, yStart)); this.addSlotToContainer(new Slot(this.craftMatrix, 2, xStart + (18 * 2), yStart)); this.addSlotToContainer(new Slot(this.craftMatrix, 3, xStart + (18 * 3), yStart)); this.addSlotToContainer(new Slot(this.craftMatrix, 4, xStart + (18 * 4), yStart)); this.addSlotToContainer(new Slot(this.craftMatrix, 5, xStart + (18 * 5), yStart)); this.addSlotToContainer(new Slot(this.craftMatrix, 6, xStart + (18 * 6), yStart)); // Row 2 ... You get the picture // Row 3 ... // Row 4 ... // Row 5 ... // Row 6 ... // Row 7 ... All the way to: this.addSlotToContainer(new Slot(this.craftMatrix, 48, xStart + (18 * 6), yStart + (18 * 6))); // Player Inventory xStart = 8; yStart = 150; for (int l = 0; l < 3; ++l) { for (int k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(player.inventory, k + l * 9 + 9, xStart + k * 18, l * 18 + yStart)); } } // Player Hotbar xStart = 8; yStart = 208; for (int i1 = 0; i1 < 9; ++i1) { this.addSlotToContainer(new Slot(player.inventory, i1, xStart + i1 * 18, yStart)); } this.onCraftMatrixChanged(this.craftMatrix); } @Override public void onCraftMatrixChanged(IInventory inventoryIn) { craftResult.setInventorySlotContents(0, StationCraftingManager.INSTANCE.findMatchingRecipe(craftMatrix, worldRef)); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack previous = ItemStack.EMPTY; Slot slot = (Slot) this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); if (index < this.handler.getSlots()) { // From the conveyor's inventory to player's inventory if (!this.mergeItemStack(current, handler.getSlots(), handler.getSlots() + 36, true)) return ItemStack.EMPTY; } else { // From the player's inventory to conveyor's inventory if (!this.mergeItemStack(current, 0, handler.getSlots(), false)) return ItemStack.EMPTY; } if (current.getCount() == 0) slot.putStack(ItemStack.EMPTY); else slot.onSlotChanged(); if (current.getCount() == previous.getCount()) return null; slot.onTake(playerIn, current); } return previous; } public void onContainerClosed(EntityPlayer playerIn) { super.onContainerClosed(playerIn); if (!this.worldRef.isRemote) { for (int i = 0; i < 9; ++i) { ItemStack itemstack = this.craftMatrix.removeStackFromSlot(i); if (!itemstack.isEmpty()) { playerIn.dropItem(itemstack, false); } } } } @Override public boolean canInteractWith(EntityPlayer playerIn) { return !playerIn.isSpectator(); } } Crafting Manager public class StationCraftingManager { public static final StationCraftingManager INSTANCE = new StationCraftingManager(); private final List<IRecipe> recipes = Lists.<IRecipe>newArrayList(); public static StationCraftingManager getInstance() { return INSTANCE; } public StationCraftingManager() { FactoriCraftingRecipes.InitializeStationRecipes(this); Collections.sort(this.recipes, new StationRecipeSorter<IRecipe>(this)); } // Copied from vanilla public StationShapedRecipes addRecipe(ItemStack stack, Object... recipeComponents) { String s = ""; int i = 0; int j = 0; int k = 0; if (recipeComponents[i] instanceof String[]) { String[] astring = (String[])((String[])recipeComponents[i++]); for (String s2 : astring) { ++k; j = s2.length(); s = s + s2; } } else { while (recipeComponents[i] instanceof String) { String s1 = (String)recipeComponents[i++]; ++k; j = s1.length(); s = s + s1; } } Map<Character, ItemStack> map; for (map = Maps.<Character, ItemStack>newHashMap(); i < recipeComponents.length; i += 2) { Character character = (Character)recipeComponents[i]; ItemStack itemstack = ItemStack.EMPTY; if (recipeComponents[i + 1] instanceof Item) { itemstack = new ItemStack((Item)recipeComponents[i + 1]); } else if (recipeComponents[i + 1] instanceof Block) { itemstack = new ItemStack((Block)recipeComponents[i + 1], 1, 32767); } else if (recipeComponents[i + 1] instanceof ItemStack) { itemstack = (ItemStack)recipeComponents[i + 1]; } map.put(character, itemstack); } ItemStack[] aitemstack = new ItemStack[j * k]; for (int l = 0; l < j * k; ++l) { char c0 = s.charAt(l); if (map.containsKey(Character.valueOf(c0))) { aitemstack[l] = ((ItemStack)map.get(Character.valueOf(c0))).copy(); } else { aitemstack[l] = ItemStack.EMPTY; } } StationShapedRecipes shapedrecipes = new StationShapedRecipes(j, k, aitemstack, stack); this.recipes.add(shapedrecipes); return shapedrecipes; } // Copied from vanilla public void addShapelessRecipe(ItemStack stack, Object... recipeComponents) { List<ItemStack> list = Lists.<ItemStack>newArrayList(); for (Object object : recipeComponents) { if (object instanceof ItemStack) { list.add(((ItemStack)object).copy()); } else if (object instanceof Item) { list.add(new ItemStack((Item)object)); } else { if (!(object instanceof Block)) { throw new IllegalArgumentException("Invalid shapeless recipe: unknown type " + object.getClass().getName() + "!"); } list.add(new ItemStack((Block)object)); } } this.recipes.add(new ShapelessRecipes(stack, list)); } public void addRecipe(IRecipe recipe) { this.recipes.add(recipe); } public ItemStack findMatchingRecipe(InventoryCrafting craftMatrix, World worldIn) { for (IRecipe irecipe : this.recipes) { if (irecipe.matches(craftMatrix, worldIn)) { return irecipe.getCraftingResult(craftMatrix); } } return ItemStack.EMPTY; } // Copied from vanilla // Could this be the problem? public NonNullList<ItemStack> getRemainingItems(InventoryCrafting craftMatrix, World worldIn) { for (IRecipe irecipe : this.recipes) { if (irecipe.matches(craftMatrix, worldIn)) { return irecipe.getRemainingItems(craftMatrix); } } NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>withSize(craftMatrix.getSizeInventory(), ItemStack.EMPTY); for (int i = 0; i < nonnulllist.size(); ++i) { nonnulllist.set(i, craftMatrix.getStackInSlot(i)); } return nonnulllist; } public List<IRecipe> getRecipeList() { return this.recipes; } The shaped and shapeless recipe classes are just copied from vanilla too, but altered to accommodate for a 7x7 recipe size. In case you're wondering WHY 7x7? It's that or wormhole crafting and I have plans to make it easier using blueprints, but that's a whole other matter and shouldn't be too difficult. It's figuring out why all the stack size numbers randomly multiply by like 10,000 that's the problem. I seriously do appreciate any help that can be given.
  4. Okay, erm, What... the... ?! Either I'm a massive derp (as always), or something isn't right here! So my container broke (for a 7x7 crafting station), and I have no idea how, since it WAS working relatively fine, apart from a serious bug that I was about to get down to fixing that was causing ItemStacks to go up into the tens of thousands upon shift-clicking a crafting result. Take a look at the attached image. So apparently, when I try to open the GUI for my crafting station, and it does a little check to make sure the TileEntity at the given position is indeed the right one (to prevent bugs / TileEntity mix-ups which do apparently happen from time to time)... it fails on checking that the TileEntity is of the type TileEntityStation, but then when it prints the error into the console, and I have it print the class type for the TileEntity that was found at that position, it says that it IS indeed a TileEntityStation. I am made of questions right now. Am I missing something glaringly obvious here, or is this actually a bug?
  5. So I've been fiddling about with these a little bit. I can't figure out how to make it rotate the parts and render them. Please could you be so kind as to provide some intel on how to actually make this work? I've Googled for hours and tried so many things, dug through a lot of Minecraft's code and every time I try something, it just renders the model as it's normal static model. To recap what I'm looking to do: Place my block (with a custom model) in 1 of 4 horizontal directions, depending on where on the block I click (See ImmersiveEngineering's conveyor belt for an example) Rotate 5 of the model's parts constantly, over time, perpendicular to the block's placement direction Render the other 3 parts normally It seems other people are having similar difficulties too. There's no documentation, tutorials etc for TESR's, and the small amount of information I've been able to excavate from the deep crevices of the god damn internet has been so unsubstantial that I might as well have asked my dead cat. Hopefully anyone readying this knows at least enough to help a tired programmer out? Also please take into consideration that I only know the most basic level of OGL. Rendering things isn't my forté Many thanks. -Logiq
  6. So far, as a temporary solution before I change to this "AxisAlignedBB" nonsense, this is how I've achieved the ranged damage: TileEntity class: private final float RANGE = 150.0F; @Override public void update() { if (!world.isRemote /*&& world.getMinecraftServer().getPlayerList().getCurrentPlayerCount() > 0*/) { // TODO change to use AABB's PlayerList players = world.getMinecraftServer().getPlayerList(); for (int i = 0; i < players.getCurrentPlayerCount(); i++) { EntityPlayerMP p = players.getPlayers().get(i); float distance = (float) pos.distanceSq(p.getPosition()); if (distance <= RANGE) { float percent = 100.0F - ((distance / RANGE) * 100.0F); Random rand = new Random(); float a = ((distance / RANGE) * 100.0F) / 100; int randomInt = (int) (a * rand.nextInt(30)); if (randomInt < 0) randomInt = 1; if (randomInt == 0) { p.attackEntityFrom(Factori.radiation, 0.5F); } } } } }
  7. I've heard TESR's are best avoided due to being performance intensive, I guess that might not be true for the fast one though? How may I reference / access my model's parts via the Java code? Also thanks for the quick response
  8. So I know, I know... people have asked about things like this before. But from what I've seen, nobody's given a simple, straightforward explanation, which is all I need. I have a custom model, not too complex, just 8 parts is all. I would like to be able to have 5 of these parts rotating constantly (based on a boolean variable in the TileEntity being true), around ONE of their local axes (preferably in a way that is block-rotation friendly). Obviously this would be on a per-block basis. Iiiii... do not know how to do this. I'm no JSON guru, and in fact, I don't like JSON ~.~ I hear Forge has some sort of animation system, using joints and what-not? This sounds great. If some legend can give me the most basic run-down of how I can achieve such a seemingly simple goal like rotating some model parts constantly around one of their own axes (either X or Z, one of the two), that'd be great, since so far everyone just says "here go look at this" and pastes a link, that takes you to a piece of code from someone's mod where you can see the JSON file, but there's no explanation (or a really, REALLY poor one that's incomprehensible), and that's it -.- If this can be done in the JSON file or the TileEntity or the Block, which-ever's best, as long as it's server friendly and works. I don't know what the most optimized option would be, considering players are likely to want a lot of these blocks in their world, but I'm sure someone somewhere does. Many thanks for reading, and if you try to help... extra thanks and a hypothetical cold beer on me! ^.^
  9. Hey, I'm just wondering, as I'm also using Forge 1.11.2, how come you don't have to pass the RenderCustomCow class a RenderManager when you instantiate it in the ClientProxy? As I'm trying to make a tile entity renderer for a block which can draw lines in the world (for testing purposes) and having no luck as I have no clue what it wants a RenderManager for or where to get/make one. Edit: Nevermind, I realized it's not an Entity, it's a TileEntity. *DERP*
  10. Hello, what is your error message? Please tell me what it says when the error occurs. Google Translation: Bonjour, quel est votre message d'erreur? Dites-moi ce qu'il dit lorsque l'erreur se produit.
  11. Thank you ever so much for your useful and well-formatted response. Yes, I've been trying to do this whilst extremely tired and to be honest, I didn't really have any idea what I was doing. But I've since slept properly and can think clearly enough to get the job done. I appreciate your help very very much. I'm almost ready to close this thread and mark it as resolved,but first I'm going to ensure everything's working properly so I can post the results for anyone who needs it in the future.
  12. Sorry for my terrible tired programming, I changed one line of code and now it works I realized I was getting the world from Minecraft.getMinecraft() for literally no reason, *derp* As for ticking entities, how would I go about doing that? TileEntities are confusing to me at the best of times. I'd like to be able to dynamically change the frequency of damage and damage amount based on how close players are. As for AABB's, I don't really understand those either. I feel stupid since I'm normally good at programming, but these things don't have enough comments in Minecraft and Forge's code
  13. Have you made sure to download the correct installer/tried the Installer-Win? Also try right-clicking the installer and choosing 'Run as Administrator'. If none of that works get back to me Installer-Win: http://adfoc.us/serve/sitelinks/?id=271228&url=http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.11.2-13.20.0.2294/forge-1.11.2-13.20.0.2294-installer-win.exe
  14. Okay, so I have an item which damages players holding it randomly, using .attackEntityFrom and a custom damage source. This works fine. I also have a block which when placed in the world, damages nearby players on a randomTick event, or at least it's supposed to. I've got it to detect all players who're nearby, but when I try to perform the attackEntityFrom, it returns false, and I'm not quite sure why. My function looks like this: @Override public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random) { System.out.println("Random Tick"); List<EntityPlayer> players = Minecraft.getMinecraft().world.playerEntities; System.out.println("----- Found " + players.size() + " players"); for (int i = 0; i < players.size(); i++) { EntityPlayer p = players.get(i); System.out.println("----- Testing " + p.getName()); if (pos.distanceSq(p.getPosition()) < 10.0D) { System.out.println("----- Test positive"); if (p.attackEntityFrom(Factori.radiation, 3)) { System.out.println("----- Success"); } else System.out.println("----- Failed :("); } } } And the damage source is as follows: public static DamageSource radiation = new DamageSource("radiation").setDamageAllowedInCreativeMode(); The console gives results such as: ...every now and then, when standing near the block. My question is: Why does the .attackEntityFrom() function return false when used in a Block class? Another side question: Am I able to increase the random tick chance to make it more frequent?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.