Jump to content

poison64

Members
  • Posts

    6
  • Joined

  • Last visited

Recent Profile Visitors

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

poison64's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. @diesieben07, thank You for your answer Just one follow up... So how do people actually learn these things? Just by scouring the forums, random tutorial pages and source codes?
  2. Hi, in the documentation of forge (1.16.x) I've found this quote: "If you are placing a Block, call Block#getDefaultState() to get the “default” state(...)" Now when I try to use code such as below: BlockState newBlockState = Blocks.DIRT.getDefaultState(); I get this error: /home/poison64/dev/mc-forge/first/src/main/java/com/example/examplemod/MyModEventHandler.java:23: error: cannot find symbol BlockState newBlockState = Blocks.DIRT.getDefaultState(); ^ symbol: method getDefaultState() location: variable DIRT of type Block 1 error Is the documentation wrong or I just don't know something? I've played around with other stuff, and they work just fine, for example, this one works as expected: @SubscribeEvent public void pickupItem(EntityItemPickupEvent event) { ItemStack stack = event.getItem().getItem(); stack.setCount(stack.getCount()*2); }
  3. Nevermind, i've figured it out The problem was that i've stored my loot table file in \assets\poc\loot_tables\blocks\schody.json instead of \data\poc\loot_tables\blocks\schody.json
  4. Hi, i've created a custom block like this: @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void onBlocksRegistry(final RegistryEvent.Register<Block> event) { schodyBlock = new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(5)).setRegistryName("poc", "schody"); event.getRegistry().register(schodyBlock); } @SubscribeEvent public static void onItemRegistry(final RegistryEvent.Register<Item> event) { schodyItem = new BlockItem(schodyBlock, new BlockItem.Properties().group(ItemGroup.MISC)).setRegistryName("poc", "schody"); event.getRegistry().register(schodyItem); } } and added a loot table in \assets\poc\loot_tables\blocks\schody.json in like this: { "type": "minecraft:block", "pools": [ { "rolls": 1, "entries": [ { "type": "minecraft:item", "name": "poc:schody" } ] } ] } and i've expected for the block to drop an item of this block when i destroy it, but unfortunatelly it doesn't Any ideas would be much appreciated. I've already went through a couple of videos and tutorials but can't pin the problem..
  5. I'm aware of that, it's just a proof of concept. I had enums defining type in constructor before.
  6. Hi, i'm trying to create a custom FilledMapItem which are filled with one color. When I had one map (white) everything worked fine. The problem is that after creating a second map both maps appear the same and are flickering with white and black colors. I don't know where else to search for help with this package com.example.examplemod; import net.minecraft.block.material.MaterialColor; import net.minecraft.entity.Entity; import net.minecraft.item.FilledMapItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.storage.MapData; public class ModImageMapItem extends FilledMapItem { public ModImageMapItem(Item.Properties builder) { super(builder); } protected MapData getCustomMapData(ItemStack stack, World worldIn) { MapData mapdata = func_219994_a(stack, worldIn); if (mapdata == null && !worldIn.isRemote) { mapdata = createMapData(stack, worldIn, worldIn.getWorldInfo().getSpawnX(), worldIn.getWorldInfo().getSpawnZ(), 3, false, false, worldIn.dimension.getType()); } drawMyMap(worldIn, null, mapdata, this); return mapdata; } private static MapData createMapData(ItemStack p_195951_0_, World p_195951_1_, int p_195951_2_, int p_195951_3_, int p_195951_4_, boolean p_195951_5_, boolean p_195951_6_, DimensionType p_195951_7_) { int i = p_195951_1_.getNextMapId(); MapData mapdata = new MapData(func_219993_a(i)); mapdata.func_212440_a(p_195951_2_, p_195951_3_, p_195951_4_, p_195951_5_, p_195951_6_, p_195951_7_); p_195951_1_.func_217399_a(mapdata); p_195951_0_.getOrCreateTag().putInt("map", i); return mapdata; } public void updateMapData(World worldIn, Entity viewer, MapData mapdata) { drawMyMap(worldIn, viewer, mapdata, this); } private static void drawMyMap(World worldIn, Entity viewer, MapData mapdata, ModImageMapItem item) { byte bColor = 0; if (item.getName().toString().contains("item.poison64.image_map_white")) { bColor = (byte)(MaterialColor.SNOW.colorIndex*4+2); } else if (item.getName().toString().contains("item.poison64.image_map_black")) { bColor = (byte)(MaterialColor.BLACK.colorIndex*4+2); } for(int x=0;x<128;x++) { for(int y=0;y<128;y++) { mapdata.colors[y*128+x] = bColor; mapdata.updateMapData(x, y); } } mapdata.mapDecorations.clear(); mapdata.trackingPosition = false; mapdata.markDirty(); } } new ModImageMapItem(new Item.Properties().group(ItemGroup.MISC).rarity(Rarity.RARE)).setRegistryName("poison64", "image_map_white"), new ModImageMapItem(new Item.Properties().group(ItemGroup.MISC).rarity(Rarity.RARE)).setRegistryName("poison64", "image_map_black") Thanks in advance, poison64
×
×
  • Create New...

Important Information

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