net.minecraft.item.Items Java Examples

The following examples show how to use net.minecraft.item.Items. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Protocol_1_13_2.java    From multiconnect with MIT License 6 votes vote down vote up
private void mutateItemRegistry(ISimpleRegistry<Item> registry) {
    registry.unregister(Items.CROSSBOW);
    registry.unregister(Items.BLUE_DYE);
    registry.unregister(Items.BROWN_DYE);
    registry.unregister(Items.BLACK_DYE);
    registry.unregister(Items.WHITE_DYE);
    registry.unregister(Items.LEATHER_HORSE_ARMOR);
    registry.unregister(Items.SUSPICIOUS_STEW);
    registry.unregister(Items.SWEET_BERRIES);
    registry.unregister(Items.FLOWER_BANNER_PATTERN);
    registry.unregister(Items.CREEPER_BANNER_PATTERN);
    registry.unregister(Items.SKULL_BANNER_PATTERN);
    registry.unregister(Items.MOJANG_BANNER_PATTERN);
    registry.unregister(Items.GLOBE_BANNER_PATTERN);
    rename(registry, Items.OAK_SIGN, "sign");
    rename(registry, Items.RED_DYE, "rose_red");
    rename(registry, Items.GREEN_DYE, "cactus_green");
    rename(registry, Items.YELLOW_DYE, "dandelion_yellow");
    rename(registry, Items.SMOOTH_STONE_SLAB, "stone_slab");

    registry.unregister(Items.CAT_SPAWN_EGG);
    insertAfter(registry, Items.MULE_SPAWN_EGG, Items.CAT_SPAWN_EGG, "ocelot_spawn_egg");
}
 
Example #2
Source File: StringEventHandling.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SubscribeEvent
public void entityDrops(LivingDropsEvent ev)
{
    if (!ConfigManager.SERVER.dropStringFromSheep.get())
        return;

    Entity entity = ev.getEntity();
    if (!(entity instanceof SheepEntity))
        return;

    Collection<ItemEntity> drops = ev.getDrops();
    if (drops instanceof ImmutableList)
    {
        SurvivalistMod.LOGGER.warn("WARNING: Some mod is returning an ImmutableList, replacing drops will NOT be possible.");
        return;
    }

    if (rnd.nextFloat() < 0.25f)
        drops.add(new ItemEntity(entity.getEntityWorld(), entity.getPosX(), entity.getPosY(), entity.getPosZ(), new ItemStack(Items.STRING)));
}
 
Example #3
Source File: AuthorCmd.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void call(String[] args) throws CmdException
{
	if(args.length == 0)
		throw new CmdSyntaxError();
	
	if(!MC.player.abilities.creativeMode)
		throw new CmdError("Creative mode only.");
	
	ItemStack heldItem = MC.player.inventory.getMainHandStack();
	int heldItemID = Item.getRawId(heldItem.getItem());
	int writtenBookID = Item.getRawId(Items.WRITTEN_BOOK);
	
	if(heldItemID != writtenBookID)
		throw new CmdError(
			"You must hold a written book in your main hand.");
	
	String author = String.join(" ", args);
	heldItem.putSubTag("author", StringTag.of(author));
}
 
Example #4
Source File: AutoTotem.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public void onUpdate() {
	if (this.isToggled()) {
		if (mc.player.getHeldItemOffhand().getItem() == Items.TOTEM_OF_UNDYING) return;
		
		/*Inventory*/
		for (int i = 9; i < 44; i++) {
			if (mc.player.inventory.getStackInSlot(i).getItem() == Items.TOTEM_OF_UNDYING) {
				mc.playerController.windowClick(0, i, 0, ClickType.PICKUP, mc.player);
				mc.playerController.windowClick(0, 45, 0, ClickType.PICKUP, mc.player);
				return;
			}
		}
		
		/*Hotbar*/
		for (int i = 0; i < 8; i++) {
			if (mc.player.inventory.getStackInSlot(i).getItem() == Items.TOTEM_OF_UNDYING) {
				//int oldSlot = mc.player.inventory.currentItem;
				mc.player.inventory.currentItem = i;
				mc.player.connection.sendPacket(new CPlayerDiggingPacket(
						Action.SWAP_HELD_ITEMS, BlockPos.ZERO, Direction.DOWN));
				//mc.player.inventory.currentItem = oldSlot;
				return;
			}
		}
	}
}
 
Example #5
Source File: AutoPotionHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private int findPotion(int startSlot, int endSlot)
{
	for(int i = startSlot; i < endSlot; i++)
	{
		ItemStack stack = MC.player.inventory.getStack(i);
		
		// filter out non-splash potion items
		if(stack.getItem() != Items.SPLASH_POTION)
			continue;
		
		// search for instant health effects
		if(hasEffect(stack, StatusEffects.INSTANT_HEALTH))
			return i;
	}
	
	return -1;
}
 
Example #6
Source File: ExtraElytraHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdate()
{
	if(jumpTimer > 0)
		jumpTimer--;
	
	ItemStack chest = MC.player.getEquippedStack(EquipmentSlot.CHEST);
	if(chest.getItem() != Items.ELYTRA)
		return;
	
	if(MC.player.isFallFlying())
	{
		if(stopInWater.isChecked() && MC.player.isTouchingWater())
		{
			sendStartStopPacket();
			return;
		}
		
		controlSpeed();
		controlHeight();
		return;
	}
	
	if(ElytraItem.isUsable(chest) && MC.options.keyJump.isPressed())
		doInstantFly();
}
 
Example #7
Source File: GameBlockStore.java    From XRay-Mod with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method is used to fill the store as we do not intend to update this after
 * it has been populated, it's a singleton by nature but we still need some
 * amount of control over when it is populated.
 */
public void populate()
{
    // Avoid doing the logic again unless repopulate is called
    if( this.store.size() != 0 )
        return;

    for ( Item item : ForgeRegistries.ITEMS ) {
        if( !(item instanceof net.minecraft.item.BlockItem) )
            continue;

        Block block = Block.getBlockFromItem(item);
        if ( item == Items.AIR || block == Blocks.AIR || Controller.blackList.contains(block) )
            continue; // avoids troubles

        store.add(new BlockWithItemStack(block, new ItemStack(item)));
    }
}
 
Example #8
Source File: CmdSkull.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCommand(String command, String[] args) throws Exception {
	ItemStack item = new ItemStack(Items.PLAYER_HEAD, 64);
	
	if (args.length < 2) {
		item.setTag(StringNbtReader.parse("{SkullOwner:{Name:\"" + args[0] + "\"}}"));
	} else if (args[0].equalsIgnoreCase("img")) {
		CompoundTag tag = StringNbtReader.parse("{SkullOwner:{Id:\"" + UUID.randomUUID() + "\",Properties:{textures:[{Value:\""
				+ Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"" + args[1] + "\"}}}").getBytes())
				+ "\"}]}}}");
		item.setTag(tag);
		System.out.println(tag);
	}
	
	mc.player.inventory.addPickBlock(item);
}
 
Example #9
Source File: AutoTotem.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (mc.player.getOffHandStack().getItem() == Items.TOTEM_OF_UNDYING) return;
	
	/* Inventory */
	for (int i = 9; i < 44; i++) {
		if (mc.player.inventory.getInvStack(i).getItem() == Items.TOTEM_OF_UNDYING) {
			mc.interactionManager.method_2906(0, 0, i, SlotActionType.PICKUP, mc.player);
			mc.interactionManager.method_2906(1, 0, 45, SlotActionType.PICKUP, mc.player);
			return;
		}
	}
	
	/* Hotbar */
	for (int i = 0; i < 8; i++) {
		if (mc.player.inventory.getInvStack(i).getItem() == Items.TOTEM_OF_UNDYING) {
			//int oldSlot = mc.player.inventory.currentItem;
			mc.player.inventory.selectedSlot = i;
			mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(
					Action.SWAP_HELD_ITEMS, BlockPos.ORIGIN, Direction.DOWN));
			//mc.player.inventory.currentItem = oldSlot;
			return;
		}
	}
}
 
Example #10
Source File: ItemContentUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static List<ItemStack> getItemsInContainer(ItemStack item) {
	List<ItemStack> items = new ArrayList<>(Collections.nCopies(27, new ItemStack(Items.AIR)));
	CompoundTag nbt = item.getTag();
	
	if (nbt != null && nbt.containsKey("BlockEntityTag")) {
		CompoundTag nbt2 = nbt.getCompound("BlockEntityTag");
		if (nbt2.containsKey("Items")) {
			ListTag nbt3 = (ListTag) nbt2.getTag("Items");
			for (int i = 0; i < nbt3.size(); i++) {
				items.set(nbt3.getCompoundTag(i).getByte("Slot"), ItemStack.fromTag(nbt3.getCompoundTag(i)));
			}
		}
	}
	
	return items;
}
 
Example #11
Source File: AutoFarmHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void registerPlants(List<BlockPos> blocks)
{
	HashMap<Block, Item> seeds = new HashMap<>();
	seeds.put(Blocks.WHEAT, Items.WHEAT_SEEDS);
	seeds.put(Blocks.CARROTS, Items.CARROT);
	seeds.put(Blocks.POTATOES, Items.POTATO);
	seeds.put(Blocks.BEETROOTS, Items.BEETROOT_SEEDS);
	seeds.put(Blocks.PUMPKIN_STEM, Items.PUMPKIN_SEEDS);
	seeds.put(Blocks.MELON_STEM, Items.MELON_SEEDS);
	seeds.put(Blocks.NETHER_WART, Items.NETHER_WART);
	
	plants.putAll(blocks.parallelStream()
		.filter(pos -> seeds.containsKey(BlockUtils.getBlock(pos)))
		.collect(Collectors.toMap(pos -> pos,
			pos -> seeds.get(BlockUtils.getBlock(pos)))));
}
 
Example #12
Source File: LivingEntityMixin.java    From the-hallow with MIT License 6 votes vote down vote up
@Inject(method = "drop(Lnet/minecraft/entity/damage/DamageSource;)V", at = @At("HEAD"))
public void drop(DamageSource damageSource, CallbackInfo info) {
	LivingEntity livingEntity = (LivingEntity) (Object) this;
	if (damageSource.getSource() instanceof LivingEntity && livingEntity.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT) && BeheadingEnchantment.hasBeheading((LivingEntity) damageSource.getSource())) {
		if (BeheadingEnchantment.getHead(damageSource)) {
			if (livingEntity.getType() == EntityType.WITHER_SKELETON) {
				livingEntity.dropStack(new ItemStack(Items.WITHER_SKELETON_SKULL));
			} else if (livingEntity.getType() == EntityType.SKELETON) {
				livingEntity.dropStack(new ItemStack(Items.SKELETON_SKULL));
			} else if (livingEntity.getType() == EntityType.ZOMBIE) {
				livingEntity.dropStack(new ItemStack(Items.ZOMBIE_HEAD));
			} else if (livingEntity.getType() == EntityType.CREEPER) {
				livingEntity.dropStack(new ItemStack(Items.CREEPER_HEAD));
			} else if (livingEntity.getType() == EntityType.PLAYER) {
				livingEntity.dropStack(new ItemStack(Items.PLAYER_HEAD));
			}
		}
	}
}
 
Example #13
Source File: Peek.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public void drawMapToolTip(MatrixStack matrix, Slot slot, int mX, int mY) {
	if (slot.getStack().getItem() != Items.FILLED_MAP) return;
	
	MapState data = FilledMapItem.getMapState(slot.getStack(), mc.world);
	byte[] colors = data.colors;
	
	double size = getSettings().get(3).toSlider().getValue();
	
	GL11.glPushMatrix();
	GL11.glScaled(size, size, 1.0);
	GL11.glTranslatef(0.0F, 0.0F, 300.0F);
	int x = (int) (mX*(1/size) + 12*(1/size));
	int y = (int) (mY*(1/size) - 12*(1/size) - 140);
	
	renderTooltipBox(x - 12, y + 12, 128, 128, false);
	for (byte c: colors) {
		int c1 = c & 255;
		
		if (c1 / 4 != 0) Screen.fill(matrix, x, y, x+1, y+1, getRenderColorFix(MaterialColor.COLORS[c1 / 4].color, c1 & 3));
		if (x - (int) (mX*(1/size)+12*(1/size)) == 127) { x = (int) (mX*(1/size)+12*(1/size)); y++; }
		else x++;
	}
	
	GL11.glPopMatrix();
}
 
Example #14
Source File: ItemContentUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static List<ItemStack> getItemsInContainer(ItemStack item) {
	List<ItemStack> items = new ArrayList<>(Collections.nCopies(27, new ItemStack(Items.AIR)));
	CompoundTag nbt = item.getTag();
	
	if (nbt != null && nbt.contains("BlockEntityTag")) {
		CompoundTag nbt2 = nbt.getCompound("BlockEntityTag");
		if (nbt2.contains("Items")) {
			ListTag nbt3 = (ListTag) nbt2.get("Items");
			for (int i = 0; i < nbt3.size(); i++) {
				items.set(nbt3.getCompound(i).getByte("Slot"), ItemStack.fromTag(nbt3.getCompound(i)));
			}
		}
	}
	
	return items;
}
 
Example #15
Source File: Peek.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public void drawMapToolTip(Slot slot, int mX, int mY) {
	if (slot.getStack().getItem() != Items.FILLED_MAP) return;
	
	MapState data = FilledMapItem.getMapState(slot.getStack(), mc.world);
	byte[] colors = data.colors;
	
	double size = getSettings().get(3).toSlider().getValue();
	
	GL11.glPushMatrix();
	GL11.glScaled(size, size, 1.0);
	GL11.glTranslatef(0.0F, 0.0F, 300.0F);
	int x = (int) (mX*(1/size) + 12*(1/size));
	int y = (int) (mY*(1/size) - 12*(1/size) - 140);
	
	renderTooltipBox(x - 12, y + 12, 128, 128, false);
	for (byte c: colors) {
		int c1 = c & 255;
		
		if (c1 / 4 != 0) Screen.fill(x, y, x+1, y+1, getRenderColorFix(MaterialColor.COLORS[c1 / 4].color, c1 & 3));
		if (x - (int) (mX*(1/size)+12*(1/size)) == 127) { x = (int) (mX*(1/size)+12*(1/size)); y++; }
		else x++;
	}
	
	GL11.glPopMatrix();
}
 
Example #16
Source File: ChickenEntityMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean interactMob(PlayerEntity playerEntity_1, Hand hand_1)
{
    ItemStack stack = playerEntity_1.getStackInHand(hand_1);
    if (CarpetExtraSettings.chickenShearing && stack.getItem() == Items.SHEARS && !this.isBaby())
    {
        if (!this.world.isClient)
        {
            this.damage(DamageSource.GENERIC, 1);
            this.dropItem(Items.FEATHER, 1);
            stack.damage(1, (LivingEntity)playerEntity_1, ((playerEntity_1x) -> {
                playerEntity_1x.sendToolBreakStatus(hand_1);
            }));
        }
    }
    return super.interactMob(playerEntity_1, hand_1);
}
 
Example #17
Source File: AutoTotem.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (mc.player.getOffHandStack().getItem() == Items.TOTEM_OF_UNDYING) return;
	
	/* Inventory */
	for (int i = 9; i < 44; i++) {
		if (mc.player.inventory.getInvStack(i).getItem() == Items.TOTEM_OF_UNDYING) {
			mc.interactionManager.clickSlot(0, 0, i, SlotActionType.PICKUP, mc.player);
			mc.interactionManager.clickSlot(1, 0, 45, SlotActionType.PICKUP, mc.player);
			return;
		}
	}
	
	/* Hotbar */
	for (int i = 0; i < 8; i++) {
		if (mc.player.inventory.getInvStack(i).getItem() == Items.TOTEM_OF_UNDYING) {
			//int oldSlot = mc.player.inventory.currentItem;
			mc.player.inventory.selectedSlot = i;
			mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(
					Action.SWAP_HELD_ITEMS, BlockPos.ORIGIN, Direction.DOWN));
			//mc.player.inventory.currentItem = oldSlot;
			return;
		}
	}
}
 
Example #18
Source File: CmdSkull.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCommand(String command, String[] args) throws Exception {
	ItemStack item = new ItemStack(Items.PLAYER_HEAD, 64);
	
	if (args.length < 2) {
		item.setTag(StringNbtReader.parse("{SkullOwner:{Name:\"" + args[0] + "\"}}"));
	} else if (args[0].equalsIgnoreCase("img")) {
		CompoundTag tag = StringNbtReader.parse("{SkullOwner:{Id:\"" + UUID.randomUUID() + "\",Properties:{textures:[{Value:\""
				+ Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"" + args[1] + "\"}}}").getBytes())
				+ "\"}]}}}");
		item.setTag(tag);
		System.out.println(tag);
	}
	
	mc.player.inventory.addPickBlock(item);
}
 
Example #19
Source File: Protocol_1_13_2.java    From multiconnect with MIT License 6 votes vote down vote up
@Override
public void postEntityDataRegister(Class<? extends Entity> clazz) {
    if (clazz == IllagerEntity.class)
        DataTrackerManager.registerOldTrackedData(IllagerEntity.class, OLD_ILLAGER_FLAGS, (byte)0,
                (entity, val) -> entity.setAttacking((val & 1) != 0));
    if (clazz == AbstractSkeletonEntity.class)
        DataTrackerManager.registerOldTrackedData(AbstractSkeletonEntity.class, OLD_SKELETON_ATTACKING, false, MobEntity::setAttacking);
    if (clazz == HorseEntity.class)
        DataTrackerManager.registerOldTrackedData(HorseEntity.class, OLD_HORSE_ARMOR, 0, (entity, val) -> {
            switch (val) {
                case 1:
                    entity.equipStack(EquipmentSlot.CHEST, new ItemStack(Items.IRON_HORSE_ARMOR));
                    break;
                case 2:
                    entity.equipStack(EquipmentSlot.CHEST, new ItemStack(Items.GOLDEN_HORSE_ARMOR));
                    break;
                case 3:
                    entity.equipStack(EquipmentSlot.CHEST, new ItemStack(Items.DIAMOND_HORSE_ARMOR));
                    break;
                default:
                    entity.equipStack(EquipmentSlot.CHEST, ItemStack.EMPTY);
            }
        });
    super.postEntityDataRegister(clazz);
}
 
Example #20
Source File: Protocol_1_15_2.java    From multiconnect with MIT License 6 votes vote down vote up
@Override
public void addExtraItemTags(TagRegistry<Item> tags, TagRegistry<Block> blockTags) {
    copyBlocks(tags, blockTags, ItemTags.CRIMSON_STEMS, BlockTags.CRIMSON_STEMS);
    copyBlocks(tags, blockTags, ItemTags.WARPED_STEMS, BlockTags.WARPED_STEMS);
    copyBlocks(tags, blockTags, ItemTags.LOGS_THAT_BURN, BlockTags.LOGS_THAT_BURN);
    copyBlocks(tags, blockTags, ItemTags.GOLD_ORES, BlockTags.GOLD_ORES);
    copyBlocks(tags, blockTags, ItemTags.SOUL_FIRE_BASE_BLOCKS, BlockTags.SOUL_FIRE_BASE_BLOCKS);
    tags.addTag(ItemTags.CREEPER_DROP_MUSIC_DISCS, ItemTags.MUSIC_DISCS);
    tags.add(ItemTags.BEACON_PAYMENT_ITEMS, Items.EMERALD, Items.DIAMOND, Items.GOLD_INGOT, Items.IRON_INGOT);
    tags.add(ItemTags.PIGLIN_REPELLENTS);
    tags.add(ItemTags.PIGLIN_LOVED);
    tags.add(ItemTags.NON_FLAMMABLE_WOOD);
    tags.add(ItemTags.STONE_TOOL_MATERIALS, Items.COBBLESTONE);
    tags.add(ItemTags.FURNACE_MATERIALS, Items.COBBLESTONE);
    super.addExtraItemTags(tags, blockTags);
}
 
Example #21
Source File: SkirtCostumeItem.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public void render(String slot, MatrixStack matrix, VertexConsumerProvider vertexConsumer, int light, PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity player, float headYaw, float headPitch) {
	ItemRenderer renderer = MinecraftClient.getInstance().getItemRenderer();
	matrix.push();
	translateToChest(model, player, headYaw, headPitch, matrix); //TODO switch back to trinkets version once it's fixed
	matrix.push();
	matrix.translate(0.25, 0.65, 0);
	matrix.scale(0.5F, 0.5F, 0.5F);
	matrix.multiply(ROTATION_CONSTANT);
	renderer.renderItem(new ItemStack(Items.BLAZE_ROD), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer);
	matrix.pop();
	matrix.push();
	matrix.translate(-0.25, 0.65, 0);
	matrix.scale(0.5F, 0.5F, 0.5F);
	matrix.multiply(ROTATION_CONSTANT);
	renderer.renderItem(new ItemStack(Items.BLAZE_ROD), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer);
	matrix.pop();
	matrix.push();
	matrix.translate(0, 0.65, 0.325);
	matrix.scale(0.5F, 0.5F, 0.5F);
	matrix.multiply(ROTATION_CONSTANT);
	renderer.renderItem(new ItemStack(Items.BLAZE_ROD), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer);
	matrix.pop();
	matrix.pop();
}
 
Example #22
Source File: ItemContentUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static List<ItemStack> getItemsInContainer(ItemStack item) {
	List<ItemStack> items = new ArrayList<>(Collections.nCopies(27, new ItemStack(Items.AIR)));
	CompoundTag nbt = item.getTag();
	
	if (nbt != null && nbt.contains("BlockEntityTag")) {
		CompoundTag nbt2 = nbt.getCompound("BlockEntityTag");
		if (nbt2.contains("Items")) {
			ListTag nbt3 = (ListTag) nbt2.get("Items");
			for (int i = 0; i < nbt3.size(); i++) {
				items.set(nbt3.getCompound(i).getByte("Slot"), ItemStack.fromTag(nbt3.getCompound(i)));
			}
		}
	}
	
	return items;
}
 
Example #23
Source File: Peek.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public void drawMapToolTip(Slot slot, int mX, int mY) {
	if (slot.getStack().getItem() != Items.FILLED_MAP) return;
	
	MapState data = FilledMapItem.getMapState(slot.getStack(), mc.world);
	byte[] colors = data.colors;
	
	double size = getSettings().get(3).toSlider().getValue();
	
	GL11.glPushMatrix();
	GL11.glScaled(size, size, 1.0);
	GL11.glTranslatef(0.0F, 0.0F, 300.0F);
	int x = (int) (mX*(1/size) + 12*(1/size));
	int y = (int) (mY*(1/size) - 12*(1/size) - 140);
	
	renderTooltipBox(x - 12, y + 12, 128, 128, false);
	for (byte c: colors) {
		int c1 = c & 255;
		
		if (c1 / 4 != 0) Screen.fill(x, y, x+1, y+1, getRenderColorFix(MaterialColor.COLORS[c1 / 4].color, c1 & 3));
		if (x - (int) (mX*(1/size)+12*(1/size)) == 127) { x = (int) (mX*(1/size)+12*(1/size)); y++; }
		else x++;
	}
	
	GL11.glPopMatrix();
}
 
Example #24
Source File: VillagerEntity_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "canGather", at = @At("HEAD"), cancellable = true)
private void canClericGather(Item item, CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetExtraSettings.clericsFarmWarts && item == Items.NETHER_WART &&
            getVillagerData().getProfession()== VillagerProfession.CLERIC )
    {
        cir.setReturnValue(true);
    }
}
 
Example #25
Source File: ItemFrameEntity_comparatorReadsClockMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void tick() {
    if(CarpetExtraSettings.comparatorReadsClock && this.getHeldItemStack().getItem() == Items.CLOCK) {
        //This doesn't handle time set commands yet

        //Every 1500 ticks, increase signal strength by one, so update comparators exactly then
        if(this.world.getTimeOfDay() % 1500 == 0 || firstTick) {
            firstTick = false;
            if(this.attachmentPos != null) {
                this.world.updateHorizontalAdjacent(this.attachmentPos, Blocks.AIR);
            }
        }
    }
    super.tick();
}
 
Example #26
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public void render(int mX, int mY) {
	TextRenderer textRend = MinecraftClient.getInstance().textRenderer;
	
	if (dragging) {
		x2 = (x2 - x1) + mX - dragOffX;
		y2 = (y2 - y1) + mY - dragOffY;
		x1 = mX - dragOffX;
		y1 = mY - dragOffY;
	}
	
	drawBar(mX, mY, textRend);
	
	for (WindowButton w: buttons) {
		int bx1 = x1 + w.x1;
		int by1 = y1 + w.y1;
		int bx2 = x1 + w.x2;
		int by2 = y1 + w.y2;
		
		Screen.fill(bx1, by1, bx2 - 1, by2 - 1, 0xffb0b0b0);
		Screen.fill(bx1 + 1, by1 + 1, bx2, by2, 0xff000000);
		Screen.fill(bx1 + 1, by1 + 1, bx2 - 1, by2 - 1,
				selected && mX >= bx1 && mX <= bx2 && mY >= by1 && mY <= by2 ? 0xff959595 : 0xff858585);
		textRend.drawWithShadow(w.text, bx1 + (bx2 - bx1) / 2 - textRend.getStringWidth(w.text) / 2, by1 + (by2 - by1) / 2 - 4, -1);
	}
	
	/* window icon */
	if (icon != null && selected) {
		GL11.glPushMatrix();
		GL11.glScaled(0.55, 0.55, 1);
		DiffuseLighting.enableGuiDepthLighting();
		MinecraftClient.getInstance().getItemRenderer().renderGuiItem(icon, (int)((x1 + 3) * 1/0.55), (int)((y1 + 3) * 1/0.55));
		GL11.glPopMatrix();
	}
	
	/* window title */
	textRend.drawWithShadow(title, x1 + (icon == null || !selected || icon.getItem() == Items.AIR ? 4 : 15), y1 + 3, -1);
}
 
Example #27
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "keepRunning", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/inventory/BasicInventory;getInvSize()I"
))
private int plantWart(BasicInventory basicInventory, ServerWorld serverWorld, VillagerEntity villagerEntity, long l)
{
    if (isFarmingCleric) // fill cancel that for loop by setting length to 0
    {
        for(int i = 0; i < basicInventory.getInvSize(); ++i)
        {
            ItemStack itemStack = basicInventory.getInvStack(i);
            boolean bl = false;
            if (!itemStack.isEmpty())
            {
                if (itemStack.getItem() == Items.NETHER_WART)
                {
                    serverWorld.setBlockState(currentTarget, Blocks.NETHER_WART.getDefaultState(), 3);
                    bl = true;
                }
            }

            if (bl)
            {
                serverWorld.playSound(null,
                        currentTarget.getX(), currentTarget.getY(), this.currentTarget.getZ(),
                        SoundEvents.ITEM_NETHER_WART_PLANT, SoundCategory.BLOCKS, 1.0F, 1.0F);
                itemStack.decrement(1);
                if (itemStack.isEmpty())
                {
                    basicInventory.setInvStack(i, ItemStack.EMPTY);
                }
                break;
            }
        }
        return 0;

    }
    return basicInventory.getInvSize();
}
 
Example #28
Source File: ItemFrameEntity_comparatorReadsClockMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "getComparatorPower", at =  @At("HEAD"),cancellable = true)
private void giveClockPower(CallbackInfoReturnable<Integer> cir) {
    if(CarpetExtraSettings.comparatorReadsClock && this.getHeldItemStack().getItem() == Items.CLOCK) {
        int power;
        //Every 1500 ticks, increase signal strength by one
        power = (int)(this.world.getTimeOfDay() % 24000) / 1500;
        //in case negative time of day every happens, make comparator output the according positive value
        if(power < 0)
            power = power + 16;
        cir.setReturnValue(power);
        cir.cancel();
    }
}
 
Example #29
Source File: PlayerEntity_antiCheatDisabled.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "method_23668", at = @At("HEAD"), cancellable = true)
private void allowDeploys(CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetSettings.antiCheatDisabled && CarpetServer.minecraft_server != null && CarpetServer.minecraft_server.isDedicated())
    {
        ItemStack itemStack_1 = getEquippedStack(EquipmentSlot.CHEST);
        if (itemStack_1.getItem() == Items.ELYTRA && ElytraItem.isUsable(itemStack_1)) {
            method_23669();
            cir.setReturnValue(true);
        }
    }
}
 
Example #30
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "shouldRun", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;",
        ordinal = 0
))
private Item disguiseWartAsSeeds(ItemStack itemStack, ServerWorld serverWorld, VillagerEntity villagerEntity)
{
    Item item = itemStack.getItem();
    if (isFarmingCleric && item == Items.NETHER_WART)
        return Items.WHEAT_SEEDS;
    return item;
}