Jump to content

kingdadrules

Members
  • Posts

    15
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

kingdadrules's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thanks for pointing those out, I will rethink & rewrite with both points in mind. This illustrates once again the danger of using popular modding guides/examples to model ones code on, as all 3 I looked through do this ItemStack modification & run the update code on both client & server.
  2. I have coded a custom generator and it functions 100% correctly apart from one issue. When a hopper is attached and fuel items fed in, the first item is consumed without producing any energy. This does not happen when fuel items are added via the inventory. The relevant code: public class TileEntityGenerator extends TileEntity implements ITickable { public ItemStackHandler handler = new ItemStackHandler(1); public EnergyStorage storage = new EnergyStorage(100000); // energy is used as an easy means of saving level of storage to NBT. public int energy = storage.getEnergyStored(); public int burnTime = 0; public int maxItemBurnTime = 0; public int producingEnergy; @Override public void update() { if (burnTime == 0 && !handler.getStackInSlot(0).isEmpty() ) { maxItemBurnTime = getItemMaxBurnTime(handler.getStackInSlot(0)); } IBlockState iblockstate = world.getBlockState(pos); final int FLAGS = 3; // Block update + send change to clients. world.notifyBlockUpdate(pos, iblockstate, iblockstate, FLAGS); producingEnergy = 0; if ( maxItemBurnTime > 0 && !(storage.getEnergyStored() == storage.getMaxEnergyStored()) ) { if (burnTime == 0) {handler.getStackInSlot(0).shrink(1);} producingEnergy = 1; burnTime++; storage.receiveEnergy(20, false); energy += 20; if (burnTime >= maxItemBurnTime) { burnTime = 0; maxItemBurnTime = 0; } } } // returns the number of ticks the given item will burn. Returns 0 if the given item is not a valid fuel public static short getItemMaxBurnTime(ItemStack stack) { int burntime = TileEntityFurnace.getItemBurnTime(stack); // just use the vanilla values return (short)MathHelper.clamp(burntime, 0, Short.MAX_VALUE); } If I remove the line: if (burnTime == 0) {handler.getStackInSlot(0).shrink(1);} The item is actually fed in from the hopper, which seems to indicate that the issue is with my code block rather than with Item Handlers, etc. My Capabilities just in case: @SuppressWarnings("unchecked") @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if(capability == CapabilityEnergy.ENERGY) return (T)this.storage; if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T)this.handler; return super.getCapability(capability, facing); } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { if(capability == CapabilityEnergy.ENERGY) return true; if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return true; return super.hasCapability(capability, facing); } This is my first forray into using Capabilities, but my limited understanding looking through the hopper code tells me that it drives the fuel item insert, so I wonder if this could cause an issue. I welcome any help, as I'm stumped with this one at the moment.
  3. That was the pointer I needed, I can't understand why I didn't pick this up from my trawling online. ResourceLocation loc = new ResourceLocation(testmod.modId + ":" + "sword2Use"); PositionedSoundRecord MyPSR = new PositionedSoundRecord(loc, SoundCategory.PLAYERS, 1.0f, 1.0f, false, 0, AttenuationType.LINEAR, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ()); event.setResultSound(MyPSR); Has done the trick. Thanks once again for your help & patience.
  4. I've just come back to this because I afree & realise the way to go is not to write my own implementation. I've looked & looked but I cannot see how to do what I need to do without doing this. I want to be able to return my own custom sound & also to make some sounds non-fading, which I do in a custom implementation by returning AttenuationType.LINEAR from getAttenuationType(). Any further help would be welcome & hopefully assist in my minecraft & java learning path.
  5. I forgot to mention ... I copied the class from some other code of mine & forgot to remove @SideOnly!
  6. Thanks for your advice diesieben07, it definately helped with sorting it & the type hierarchy view will come in very handy. I created my own class implementing ISound, including my custom ResourceLocation & returned this: MyISound sound = new MyISound(); event.setResultSound(sound); It works fine now. I'm slowly learning! I will look into using the correct method of creating registry entries. I copied the static initializer method from example code at the start of my modding journey & so have used it for registering everything since.
  7. I want to replace vanilla sounds with custom ones in certain circumstances in my mod. The way to do it appears to be to use PlaySoundEvent & return a new sound. I have set up a custom SoundEvent successfully, but need help with PlaySoundEvent . My SoundEvent is registered like so: public class ModSounds { public static SoundEvent sword2Use = new SoundEvent(new ResourceLocation(testmod.modId + ":" + "sword2Use")).setRegistryName("sword2Use"); public static void register(IForgeRegistry<SoundEvent> registry) { registry.registerAll( sword2Use ); } } My code so far for the PlaySoundEvent Listener: public class SoundPlays { @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) @SideOnly(Side.CLIENT) public void soundPlay(PlaySoundEvent event) { EntityPlayer player = Minecraft.getMinecraft().player; if (player != null && player.getHeldItemMainhand().getItem() == ModItems.sword2) { event.setResultSound(??????); } } } I'm stuck with what to return in ??????, as I don't know how to return a SoundEvent as ISound & can't find any documentation or examples to work off. Any help appreciate.
  8. It's probably me being thick, but I'm scratching my head here. My mod places a stored structure in a custom dimension, the nbt file is accessed via "Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(main.mymod.modId +":basestructure"));" The mod works just fine & places the structure where I want it in the dimension (at a fixed location). If I then save & exit the world then either delete the world & create another with the same name, or just create another world, the structure is not generated in the new world. If I restart minecraft before I create a new world, the structure generates OK. I just can't see why the restart is needed. Any help appreciated
  9. It's probably me being thick, but I'm scratching my head here. My mod places a stored structure in a custom dimension, the nbt file is accessed via "Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(main.mymod.modId +":basestructure"));" The mod works just fine & places the structure where I want it in the dimension (at a fixed location). If I then save & exit the world then either delete the world & create another with the same name, or just create another world, the structure is not generated in the new world. If I restart minecraft before I create a new world, the structure generates OK. I just can't see why the restart is needed. Any help appreciated
  10. Thanks Jabelar for the information, just what I needed to get me on the right course. I did already digest your excellent tutorial on this (as well as your living entities one) ... that's what gave me the confidence to start untangling the convolutions. I will go with your advice re. DimensionTypes. I didn't realise McJty had a tutorial on this (I find their tutorials to be good as well), so I will work my way through that one.
  11. Or are you implying I set a new world type for each dimension, based on OVERWORLD?
  12. I plan on having at least 6 OVERWORLD dimension, so I do need to distinguish between them in the same OVERWORLD dimension type.
  13. I'm fairly new to modding & java, just starting to play with Dimension / Biome / Chink generation using minecraft 1.12 & have the following registered event listener class: public class OneBiome { @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=false) public void onBiomeGenInit(net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens event) { GenLayer replacement[] = new GenLayer[2]; replacement[0] = new GenLayerConstant(40); replacement[1] = replacement[0]; event.setNewBiomeGens(replacement); return; } } How would I obtain the World / Dimension ID so I could change the replacement Biome dependent on it? The sort of thing I want to do is: if ("DIMENSION/WORLD??" = 0) { replacement[0] = new GenLayerBIome(40) } else {replacement[0] = new GenLayerBiome(41)} I tried the approach: int world = Minecraft.getMinecraft().world.provider.getDimension(); but that returns a null value. Thanks in advance for any advice.
  14. Thanks for the pointers. I thought from the lack of up to date info on the web it might be a right can of worms . Time to bite the bullet & investigate world/chunk generation.
  15. Can someone please give me some pointers (I'm a newbie writing my first mod) to the easiest way to turn abandoned mineshaft generation off (currently using Forge Mod Loader version 14.23.1.2555 for Minecraft 1.12.2)? Basically I don't want any mineshafts to generate in the overworld at all. Thanks in advance
×
×
  • Create New...

Important Information

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