Jump to content

Def Daemon

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by Def Daemon

  1. Well changed the code into this and it works like a charm....thnx m8.... up to the fun part (BlockEntity) @Override public void neighborChanged(BlockState pState, Level pLevel, BlockPos pPos, Block pBlock, BlockPos pFromPos, boolean pIsMoving) { if (!pLevel.isClientSide) { boolean flag = pState.getValue(POWERED); if (flag != pLevel.hasNeighborSignal(pPos)) { if (flag) { pLevel.scheduleTick(pPos, this, 4); } else { pLevel.setBlock(pPos, pState.cycle(POWERED), 2); } } } UpdateCurrentState(pLevel, pState, pPos); } private void UpdateCurrentState(Level pLevel, BlockState pState, BlockPos pPos) { if(!pLevel.hasNeighborSignal(pPos)) { pState.setValue(LIT, false); } } public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Random pRand) { if (pState.getValue(POWERED) && !pLevel.hasNeighborSignal(pPos)) { pLevel.setBlock(pPos, pState.cycle(POWERED), 2); } UpdateCurrentState(pLevel, pState, pPos); }
  2. My code is now at https://github.com/DefDaemon/Extreme_Survival
  3. Well I added the following code, it doesn't change anything... What does cycle() actually do? public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, Random pRand) { if (pState.getValue(POWERED) && !pLevel.hasNeighborSignal(pPos)) { pLevel.setBlock(pPos, pState.cycle(POWERED), 2); } }
  4. Hallo all I'm trying to create a machine that works on redstone signal. The basis block contains three properties; FACING, LIT and POWERED. The idea is that this machine can only work when connected to a redstone signal so I'm using hasNeighborSignal() (in the NeighborChanged() method) to find out if there's a redstone signal. I'm using the code found in the RedstoneLampBlock class (changed LIT into POWERED of course), but the POWERED property won't change. 1. What am I doing wrong? 2. Can anyone explain the pState.cycle() method? No idea what it really does. Here's my code: public class AlloyMixerBlock extends BaseEntityBlock { public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final BooleanProperty POWERED = BlockStateProperties.POWERED; public static final BooleanProperty LIT = BlockStateProperties.LIT; public AlloyMixerBlock(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(POWERED, Boolean.valueOf(false)).setValue(LIT, Boolean.valueOf(false))); } @Override public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { if (!pLevel.isClientSide()) { BlockEntity entity = pLevel.getBlockEntity(pPos); if(entity instanceof AlloyMixerBlockEntity) { NetworkHooks.openGui(((ServerPlayer)pPlayer), (AlloyMixerBlockEntity)entity, pPos); } else { throw new IllegalStateException("Our Container provider is missing!"); } } return InteractionResult.sidedSuccess(pLevel.isClientSide()); } @Override public BlockState getStateForPlacement(BlockPlaceContext pContext) { return this.defaultBlockState().setValue(POWERED, Boolean.valueOf(pContext.getLevel().hasNeighborSignal(pContext.getClickedPos()))).setValue(FACING, pContext.getHorizontalDirection().getOpposite()).setValue(LIT, Boolean.valueOf(false)); } @Override public BlockState rotate(BlockState pState, Rotation pRotation) { return pState.setValue(FACING, pRotation.rotate(pState.getValue(FACING))); } @Override public BlockState mirror(BlockState pState, Mirror pMirror) { return pState.rotate(pMirror.getRotation(pState.getValue(FACING))); } @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) { pBuilder.add(FACING, POWERED, LIT); } @Override public RenderShape getRenderShape(BlockState pState) { return RenderShape.MODEL; } @Override public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) { if (pState.getBlock() != pNewState.getBlock()) { BlockEntity blockEntity = pLevel.getBlockEntity(pPos); if (blockEntity instanceof AlloyMixerBlockEntity) { ((AlloyMixerBlockEntity) blockEntity).drops(); } } super.onRemove(pState, pLevel, pPos, pNewState, pIsMoving); } @Nullable @Override public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { return new AlloyMixerBlockEntity(pPos, pState); } @Override public void neighborChanged(BlockState pState, Level pLevel, BlockPos pPos, Block pBlock, BlockPos pFromPos, boolean pIsMoving) { ShowCurrentState("Before NeighborChanged:", pLevel, pState, pPos); if (!pLevel.isClientSide) { boolean flag = pState.getValue(POWERED); if (flag != pLevel.hasNeighborSignal(pPos)) { if (flag) { Extreme_Survival.LOGGER.info("Flag != hasNeighborSignal and Flag = true"); pLevel.scheduleTick(pPos, this, 4); } else { Extreme_Survival.LOGGER.info("Flag != hasNeighborSignal and Flag = false"); pLevel.setBlock(pPos, pState.cycle(POWERED), 2); } } else { Extreme_Survival.LOGGER.info("Flag equals pState"); } } else { Extreme_Survival.LOGGER.info("Clientside!!!"); } ShowCurrentState("After NeighborChanged:", pLevel, pState, pPos); } // Just for debugging! private void ShowCurrentState(String title, Level pLevel, BlockState pState, BlockPos pPos) { Extreme_Survival.LOGGER.info(title); Extreme_Survival.LOGGER.info("======================================"); Extreme_Survival.LOGGER.info("hasSignal: " + pLevel.hasNeighborSignal(pPos)); Extreme_Survival.LOGGER.info("POWERED : " + pState.getValue(POWERED)); Extreme_Survival.LOGGER.info("LIT : " + pState.getValue(LIT)); Extreme_Survival.LOGGER.info("--------------------------------------"); if (!pState.getValue(POWERED)) { pLevel.setBlock(pPos, pState.setValue(LIT, Boolean.valueOf(false)), 2); } Extreme_Survival.LOGGER.info("hasSignal: " + pLevel.hasNeighborSignal(pPos)); Extreme_Survival.LOGGER.info("POWERED : " + pState.getValue(POWERED)); Extreme_Survival.LOGGER.info("LIT : " + pState.getValue(LIT)); Extreme_Survival.LOGGER.info("======================================"); } }
  5. Ah....this is exactly what I need..... thank you very much 😄
  6. Okay got that, but what about other events? What if I want to check if a player is entering a new biome? Should I use Player TickEvent to compare the old biome value with current biome value (if there is even such a thing)? Thnx for helping me out but I need in depth information about MC and Forge events
  7. Hello For my mod I need to get more familiar with events (which events are supported by MC and Forge) and time management (how day and night are working, are there events which I can use etc.) in MC. Can anyone point out a good tutorial for me? thnx
  8. Works great....thnx m8
  9. I want to strip custom logs in MC 1.17.1. In version 1.16.5 I did use an accesstransformer to set the BLOCK_STRIPPING_MAP to public and non-final. In version 1.17.1 the accesstransformer doesn't work. Anyone got a solution for this issue? This is the accesstransformer: public-f net.minecraft.world.item.AxeItem field_203176_a #STRIPPABLES
  10. Works great....thnx m8
  11. Well...actually you have to use ItemBlockRenderTypes!
  12. In order to use stack.hurtAndBreak() I need a consumer so I tried a 1.16.5 one: (player) -> player.SendBreakAnimation(context.getHand())); but apperently SendBreakAnimation doesn't exist anymore in version 1.17.1. Can anyone point me into the right direction?
  13. Well that did the trick...thnx m8
  14. Hi guys Can anyone translate this piece of 1.15 code into 1.16.5 code? I'm wanna use this to generate custom bushes randomly in the overworld, but I can't figure this part out. biome.addFeature(DecorationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(FeatureInit.BUSH_CONFIG).withPlacement(Placement.COUNT_MULTILAYER.configured(new FrequencyConfig(10))));
  15. 1. Fixed the registration for WoodenStake class...works fine now 2. Forgot to create a private variable for the soundstring. Also working fine now. thnx a lot m8
  16. 1. I did create a subclass called WoodenStake and did override the appendHooverText method but still doesn't work. 2. Clicking on the Armor Stand doesn't work, but I just found out that when clicking on the Armor Stand, the following bug appears: [17:26:44] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server java.lang.NullPointerException: null at net.minecraft.util.ResourceLocation.decompose(ResourceLocation.java:60) ~[forge:?] {re:classloading} at net.minecraft.util.ResourceLocation.<init>(ResourceLocation.java:38) ~[forge:?] {re:classloading} at com.defdaemon.horrormoon.lists.AmorMaterialList.getEquipSound(AmorMaterialList.java:61) ~[?:?] {re:classloading} at net.minecraft.entity.LivingEntity.playEquipSound(LivingEntity.java:573) ~[forge:?] {re:classloading} at net.minecraft.entity.item.ArmorStandEntity.setItemSlot(ArmorStandEntity.java:140) ~[forge:?] {re:classloading} at net.minecraft.entity.item.ArmorStandEntity.swapItem(ArmorStandEntity.java:391) ~[forge:?] {re:classloading} at net.minecraft.entity.item.ArmorStandEntity.interactAt(ArmorStandEntity.java:333) ~[forge:?] {re:classloading} at net.minecraft.network.play.ServerPlayNetHandler.handleInteract(ServerPlayNetHandler.java:1197) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CUseEntityPacket.handle(CUseEntityPacket.java:80) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CUseEntityPacket.handle(CUseEntityPacket.java:15) ~[forge:?] {re:classloading} at net.minecraft.network.PacketThreadUtil.lambda$ensureRunningOnSameThread$0(PacketThreadUtil.java:19) ~[forge:?] {re:classloading} at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:17) ~[forge:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.doRunTask(ThreadTaskExecutor.java:136) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.doRunTask(RecursiveEventLoop.java:22) ~[forge:?] {re:classloading} at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:734) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:159) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.pollTask(ThreadTaskExecutor.java:109) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:717) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:711) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.managedBlock(ThreadTaskExecutor.java:119) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:697) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:646) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_281] {} 3. Fixed this problem. changed "silver" into new ResourceLocation().
  17. Goodmorning everyone I did some work on a material called Silver...Added ores, items, recipes and armor but I stumbled into some issues: 1. Can't seem to fix the appendHoverText for my WoodenStake item. It should display "Only kills vampires..." 2. How can I put my custom silver armor onto a ArmorStand 3. I added silver horse armor. This works fine but when I put it on a horse, the texture seems missing Can you guys help me out? Thnx https://github.com/DefDaemon/Daemons_Horror_Moon
  18. Well fixed the Java Null pointer error and started working on de hurtEnemy method. thnx for your support guys
  19. Done..... https://github.com/DefDaemon/Daemons_Horror_Moon Thnx for the advise
  20. I did some research on the Internet and came up with the code below. The only problem is that "wooden_stake" is not registered (Java Nullpointer error can't find "wooden_stake). What am I missing? public Main() { instance = this; IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::setup); modEventBus.addListener(this::clientSetup); BlockList.BLOCKS.register(modEventBus); ItemList.ITEMS.register(modEventBus); EntityList.ENTITIES.register(modEventBus); MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, OreGeneration::generatesOres); MinecraftForge.EVENT_BUS.register(this); } items/WoodenStake class public class WoodenStake extends SwordItem { public WoodenStake(IItemTier tier, int attackDamageIn, float attackSpeedIn, Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } } list/ToolMaterialList public enum ToolMaterialList implements IItemTier { wooden_stake(1.0f,0.0f,1,0, 1000000, ItemList.WOODEN_STAKE.get()); private float attackDamage, efficiency; private int durability, harvestLevel, enchantability; private Item repairMaterial; private ToolMaterialList(float attackDamage, float efficiency, int durability, int harvestLevel, int enchantability, Item repairMaterial) { this.attackDamage = attackDamage; this.efficiency = efficiency; this.enchantability = enchantability; this.durability = durability; this.harvestLevel = harvestLevel; this.repairMaterial = repairMaterial; } @Override public int getUses() { return this.durability; } @Override public float getSpeed() { return this.efficiency; } @Override public float getAttackDamageBonus() { return this.attackDamage; } @Override public int getLevel() { return this.harvestLevel; } @Override public int getEnchantmentValue() { return this.enchantability; } @Override public Ingredient getRepairIngredient() { return Ingredient.of(this.repairMaterial); } } lists/ItemList public class ItemList { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Main.MOD_ID); public static final RegistryObject<Item> WOODEN_STAKE = ITEMS.register("wooden_stake", () -> new WoodenStake(ToolMaterialList.wooden_stake, 0, 6.0f, new Item.Properties().tab(ItemGroup.TAB_COMBAT))); }
  21. Okay, I will start with that... thnx m8
  22. Hello I'm a total noob when it comes to modding, but I know some basics (can create blocks, items, ores, loottables etc), but now I want to create a custom weapon. It is a simple "wooden stake" to kill vampires with it. This weapon can be used once and will be removed after a single hit. Attack speed, harvesting level etc do not apply here. My first question: Should I base this weapon on the Item class or should I write a class that inherits from the SwordItem class? My second question: Where can I check if the entity I'm attacking is a vampire? Thnx
×
×
  • Create New...

Important Information

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