├── .gitattributes ├── src └── main │ ├── resources │ ├── META-INF │ │ ├── coremods.json │ │ └── mods.toml │ ├── assets │ │ └── improvedwolves │ │ │ ├── models │ │ │ ├── block │ │ │ │ ├── red_dog_bowl.json │ │ │ │ ├── black_dog_bowl.json │ │ │ │ ├── blue_dog_bowl.json │ │ │ │ ├── brown_dog_bowl.json │ │ │ │ ├── cyan_dog_bowl.json │ │ │ │ ├── gray_dog_bowl.json │ │ │ │ ├── green_dog_bowl.json │ │ │ │ ├── lime_dog_bowl.json │ │ │ │ ├── magenta_dog_bowl.json │ │ │ │ ├── orange_dog_bowl.json │ │ │ │ ├── pink_dog_bowl.json │ │ │ │ ├── purple_dog_bowl.json │ │ │ │ ├── white_dog_bowl.json │ │ │ │ ├── yellow_dog_bowl.json │ │ │ │ ├── light_blue_dog_bowl.json │ │ │ │ ├── light_gray_dog_bowl.json │ │ │ │ └── dog_bowl.json │ │ │ └── item │ │ │ │ ├── blue_dog_bowl.json │ │ │ │ ├── cyan_dog_bowl.json │ │ │ │ ├── gray_dog_bowl.json │ │ │ │ ├── lime_dog_bowl.json │ │ │ │ ├── pink_dog_bowl.json │ │ │ │ ├── red_dog_bowl.json │ │ │ │ ├── black_dog_bowl.json │ │ │ │ ├── brown_dog_bowl.json │ │ │ │ ├── green_dog_bowl.json │ │ │ │ ├── orange_dog_bowl.json │ │ │ │ ├── purple_dog_bowl.json │ │ │ │ ├── white_dog_bowl.json │ │ │ │ ├── yellow_dog_bowl.json │ │ │ │ ├── magenta_dog_bowl.json │ │ │ │ ├── light_blue_dog_bowl.json │ │ │ │ └── light_gray_dog_bowl.json │ │ │ ├── textures │ │ │ ├── block │ │ │ │ └── dog_bowl.png │ │ │ └── gui │ │ │ │ └── container │ │ │ │ └── dog_bowl.png │ │ │ ├── sounds │ │ │ └── entity │ │ │ │ └── player │ │ │ │ └── whistle.ogg │ │ │ ├── sounds.json │ │ │ ├── blockstates │ │ │ ├── red_dog_bowl.json │ │ │ ├── blue_dog_bowl.json │ │ │ ├── cyan_dog_bowl.json │ │ │ ├── gray_dog_bowl.json │ │ │ ├── lime_dog_bowl.json │ │ │ ├── pink_dog_bowl.json │ │ │ ├── black_dog_bowl.json │ │ │ ├── brown_dog_bowl.json │ │ │ ├── green_dog_bowl.json │ │ │ ├── white_dog_bowl.json │ │ │ ├── orange_dog_bowl.json │ │ │ ├── purple_dog_bowl.json │ │ │ ├── yellow_dog_bowl.json │ │ │ ├── magenta_dog_bowl.json │ │ │ ├── light_blue_dog_bowl.json │ │ │ └── light_gray_dog_bowl.json │ │ │ └── lang │ │ │ ├── en_us.json │ │ │ ├── de_de.json │ │ │ └── en_ud.json │ ├── pack.mcmeta │ ├── data │ │ └── improvedwolves │ │ │ ├── recipes │ │ │ ├── blue_dog_bowl.json │ │ │ ├── cyan_dog_bowl.json │ │ │ ├── gray_dog_bowl.json │ │ │ ├── lime_dog_bowl.json │ │ │ ├── pink_dog_bowl.json │ │ │ ├── red_dog_bowl.json │ │ │ ├── black_dog_bowl.json │ │ │ ├── brown_dog_bowl.json │ │ │ ├── green_dog_bowl.json │ │ │ ├── orange_dog_bowl.json │ │ │ ├── purple_dog_bowl.json │ │ │ ├── white_dog_bowl.json │ │ │ ├── yellow_dog_bowl.json │ │ │ ├── magenta_dog_bowl.json │ │ │ ├── light_blue_dog_bowl.json │ │ │ └── light_gray_dog_bowl.json │ │ │ └── loot_tables │ │ │ └── blocks │ │ │ ├── blue_dog_bowl.json │ │ │ ├── cyan_dog_bowl.json │ │ │ ├── gray_dog_bowl.json │ │ │ ├── lime_dog_bowl.json │ │ │ ├── pink_dog_bowl.json │ │ │ ├── red_dog_bowl.json │ │ │ ├── black_dog_bowl.json │ │ │ ├── brown_dog_bowl.json │ │ │ ├── green_dog_bowl.json │ │ │ ├── magenta_dog_bowl.json │ │ │ ├── orange_dog_bowl.json │ │ │ ├── purple_dog_bowl.json │ │ │ ├── white_dog_bowl.json │ │ │ ├── yellow_dog_bowl.json │ │ │ ├── light_blue_dog_bowl.json │ │ │ └── light_gray_dog_bowl.json │ └── coremods │ │ └── goal-hook.js │ └── java │ └── com │ └── mrcrayfish │ └── improvedwolves │ ├── Reference.java │ ├── network │ ├── message │ │ ├── IMessage.java │ │ ├── MessageSyncHeldWolfItem.java │ │ └── MessageWolfDepositItem.java │ └── PacketHandler.java │ ├── util │ ├── InventoryUtil.java │ └── TileEntityUtil.java │ ├── inventory │ └── container │ │ ├── SlotDogBowl.java │ │ └── DogBowlContainer.java │ ├── init │ ├── ModSounds.java │ ├── ModContainers.java │ ├── ModMemoryModuleTypes.java │ ├── ModTileEntities.java │ └── ModBlocks.java │ ├── common │ ├── CommonEvents.java │ └── entity │ │ ├── PlayerDataHandler.java │ │ └── WolfHeldItemDataHandler.java │ ├── client │ ├── screen │ │ └── DogBowlScreen.java │ ├── render │ │ └── tileentity │ │ │ └── DogBowlRenderer.java │ └── ClientHandler.java │ ├── tileentity │ ├── DogBowlTileEntity.java │ └── BasicLootTileEntity.java │ ├── ImprovedWolves.java │ ├── block │ └── DogBowlBlock.java │ └── entity │ └── ai │ └── goal │ ├── MoveToDogBowlGoal.java │ └── PutInChestGoal.java ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── .gitignore ├── README.md ├── gradlew.bat ├── README.txt ├── CREDITS.txt ├── gradlew ├── changelog.txt └── LICENSE.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/coremods.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImprovedWolves": "coremods/goal-hook.js" 3 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrCrayfish/ImprovedWolves/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/red_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/black_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/brown_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/cyan_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/green_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/lime_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/magenta_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/orange_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/pink_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/purple_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/white_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/yellow_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/blue_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/cyan_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/cyan_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/gray_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/lime_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/lime_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/pink_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/pink_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/red_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/red_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/light_blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/light_gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/black_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/black_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/brown_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/brown_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/green_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/green_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/orange_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/orange_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/purple_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/purple_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/white_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/white_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/yellow_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/yellow_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/magenta_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/magenta_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/light_blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/light_blue_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/item/light_gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "improvedwolves:block/light_gray_dog_bowl" 3 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/textures/block/dog_bowl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrCrayfish/ImprovedWolves/HEAD/src/main/resources/assets/improvedwolves/textures/block/dog_bowl.png -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/sounds/entity/player/whistle.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrCrayfish/ImprovedWolves/HEAD/src/main/resources/assets/improvedwolves/sounds/entity/player/whistle.ogg -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/textures/gui/container/dog_bowl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrCrayfish/ImprovedWolves/HEAD/src/main/resources/assets/improvedwolves/textures/gui/container/dog_bowl.png -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/sounds.json: -------------------------------------------------------------------------------- 1 | { 2 | "entity.player.whistle": { 3 | "subtitle": "subtitle.improvedwolves.entity.player.whistle", 4 | "sounds": [ "improvedwolves:entity/player/whistle" ] 5 | } 6 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip 6 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/Reference.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves; 2 | 3 | /** 4 | * Author: MrCrayfish 5 | */ 6 | public class Reference 7 | { 8 | public static final String MOD_ID = "improvedwolves"; 9 | } 10 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Sets default memory used for gradle commands. Can be overridden by user or command line properties. 2 | # This is required to provide enough memory for the Minecraft decompilation process. 3 | org.gradle.jvmargs=-Xmx3G 4 | org.gradle.daemon=false -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "improved resources", 4 | "pack_format": 5, 5 | "_comment": "A pack_format of 5 requires json lang files and some texture changes from 1.15. Note: we require v5 pack meta for all mods." 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | run 23 | 24 | # Files from Forge MDK 25 | forge*changelog.txt 26 | -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:blue_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:blue_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/cyan_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:cyan_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:cyan_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:gray_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:gray_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/lime_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:lime_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:lime_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/pink_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:pink_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:pink_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/red_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:red_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:red_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/black_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:black_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:black_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/brown_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:brown_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:brown_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/green_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:green_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:green_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/orange_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:orange_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:orange_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/purple_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:purple_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:purple_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/white_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:white_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:white_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/yellow_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:yellow_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:yellow_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/magenta_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:magenta_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:magenta_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/light_blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:light_blue_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:light_blue_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/recipes/light_gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:crafting_shaped", 3 | "pattern": [ 4 | "#D#", 5 | " # " 6 | ], 7 | "key": { 8 | "D": { 9 | "item": "minecraft:light_gray_dye" 10 | }, 11 | "#": { 12 | "item": "minecraft:iron_ingot" 13 | } 14 | }, 15 | "result": { 16 | "item": "improvedwolves:light_gray_dog_bowl" 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/network/message/IMessage.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.network.message; 2 | 3 | import net.minecraft.network.PacketBuffer; 4 | import net.minecraftforge.fml.network.NetworkEvent; 5 | 6 | import java.util.function.Supplier; 7 | 8 | /** 9 | * Author: MrCrayfish 10 | */ 11 | public interface IMessage 12 | { 13 | void encode(T message, PacketBuffer buffer); 14 | 15 | T decode(PacketBuffer buffer); 16 | 17 | void handle(T message, Supplier supplier); 18 | } -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/util/InventoryUtil.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.util; 2 | 3 | import net.minecraft.item.ItemStack; 4 | 5 | /** 6 | * Author: MrCrayfish 7 | */ 8 | public class InventoryUtil 9 | { 10 | public static boolean areItemStackEqualIgnoreCount(ItemStack source, ItemStack target) 11 | { 12 | if(source.isDamaged()) 13 | return false; 14 | if(target.isDamaged()) 15 | return false; 16 | return source.getItem() == target.getItem() && ItemStack.areItemStackTagsEqual(source, target); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/red_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/red_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/red_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/red_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/red_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/blue_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/blue_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/blue_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/blue_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/cyan_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/cyan_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/cyan_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/cyan_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/cyan_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/gray_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/gray_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/gray_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/gray_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/lime_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/lime_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/lime_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/lime_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/lime_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/pink_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/pink_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/pink_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/pink_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/pink_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/black_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/black_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/black_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/black_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/black_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/brown_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/brown_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/brown_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/brown_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/brown_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/green_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/green_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/green_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/green_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/green_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/white_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/white_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/white_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/white_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/white_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/orange_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/orange_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/orange_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/orange_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/orange_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/purple_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/purple_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/purple_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/purple_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/purple_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/yellow_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/yellow_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/yellow_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/yellow_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/yellow_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:blue_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/cyan_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:cyan_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:gray_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/lime_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:lime_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/pink_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:pink_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/red_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:red_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/magenta_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/magenta_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/magenta_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/magenta_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/magenta_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/black_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:black_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/brown_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:brown_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/green_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:green_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/magenta_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:magenta_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/orange_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:orange_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/purple_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:purple_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/white_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:white_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/yellow_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:yellow_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/light_blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:light_blue_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/data/improvedwolves/loot_tables/blocks/light_gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "minecraft:block", 3 | "pools": [ 4 | { 5 | "rolls": 1, 6 | "entries": [ 7 | { 8 | "type": "minecraft:item", 9 | "functions": [ 10 | { 11 | "function": "minecraft:copy_name", 12 | "source": "block_entity" 13 | } 14 | ], 15 | "name": "improvedwolves:light_gray_dog_bowl" 16 | } 17 | ], 18 | "conditions": [ 19 | { 20 | "condition": "minecraft:survives_explosion" 21 | } 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/light_blue_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/light_blue_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/light_blue_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/light_blue_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/light_blue_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/blockstates/light_gray_dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": { 3 | "facing=north": { 4 | "model": "improvedwolves:block/light_gray_dog_bowl", 5 | "y": 0 6 | }, 7 | "facing=east": { 8 | "model": "improvedwolves:block/light_gray_dog_bowl", 9 | "y": 90 10 | }, 11 | "facing=south": { 12 | "model": "improvedwolves:block/light_gray_dog_bowl", 13 | "y": 180 14 | }, 15 | "facing=west": { 16 | "model": "improvedwolves:block/light_gray_dog_bowl", 17 | "y": 270 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![ImprovedWolves Banner](https://mrcrayfish.com/img/improvedwolves/banner.jpg) 2 | 3 | # Improved Wolves 4 | 5 | This is a simple mod which aims to improved wolves in Minecraft. Wolves will now automatically heal themselves by eating food from a dog bowl. You can press U to command your wolf to put your currently held item into the chest you are looking at. This mod is very basic for now but may be added onto in the future! 6 | 7 | ### Screenshots: 8 | 9 | ![Screenshot 1](https://mrcrayfish.com/img/improvedwolves/screenshots/Screenshot1.jpg) 10 | ![Screenshot 2](https://mrcrayfish.com/img/improvedwolves/screenshots/Screenshot2.jpg) 11 | ![Screenshot 3](https://mrcrayfish.com/img/improvedwolves/screenshots/Screenshot3.jpg) 12 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/inventory/container/SlotDogBowl.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.inventory.container; 2 | 3 | import net.minecraft.inventory.IInventory; 4 | import net.minecraft.inventory.container.Slot; 5 | import net.minecraft.item.ItemStack; 6 | 7 | /** 8 | * Author: MrCrayfish 9 | */ 10 | public class SlotDogBowl extends Slot 11 | { 12 | public SlotDogBowl(IInventory inventoryIn, int index, int xPosition, int yPosition) 13 | { 14 | super(inventoryIn, index, xPosition, yPosition); 15 | } 16 | 17 | @Override 18 | public boolean isItemValid(ItemStack stack) 19 | { 20 | return stack.getItem().getFood() != null && stack.getItem().getFood().isMeat(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/mods.toml: -------------------------------------------------------------------------------- 1 | modLoader="javafml" 2 | loaderVersion="[31,)" 3 | 4 | issueTrackerURL="https://mrcrayfish.com/mods?id=improvedwolves" 5 | 6 | [[mods]] 7 | modId="improvedwolves" 8 | version="1.1.2" 9 | displayName="Improved Wolves" 10 | updateJSONURL="https://mrcrayfish.com/mods?id=improvedwolves" 11 | displayURL="https://mrcrayfish.com/mods?id=improvedwolves" 12 | logoFile="examplemod.png" 13 | credits="@Rexxgamesss and @Jor02video on Twitter for ideas" 14 | authors="MrCrayfish" 15 | description='Makes wolves smarter!' 16 | 17 | [[dependencies.improvedwolves]] 18 | modId="forge" 19 | mandatory=true 20 | versionRange="[31,)" 21 | ordering="NONE" 22 | side="BOTH" 23 | [[dependencies.improvedwolves]] 24 | modId="minecraft" 25 | mandatory=true 26 | versionRange="[1.15.2,1.16)" 27 | ordering="NONE" 28 | side="BOTH" 29 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/init/ModSounds.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.init; 2 | 3 | import com.mrcrayfish.improvedwolves.Reference; 4 | import net.minecraft.util.ResourceLocation; 5 | import net.minecraft.util.SoundEvent; 6 | import net.minecraftforge.event.RegistryEvent; 7 | import net.minecraftforge.eventbus.api.SubscribeEvent; 8 | import net.minecraftforge.fml.common.Mod; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Author: MrCrayfish 15 | */ 16 | @Mod.EventBusSubscriber(modid = Reference.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) 17 | public class ModSounds 18 | { 19 | private static final List SOUNDS = new ArrayList<>(); 20 | 21 | public static final SoundEvent ENTITY_PLAYER_WHISTLE = register(Reference.MOD_ID + ":entity.player.whistle"); 22 | 23 | private static SoundEvent register(String name) 24 | { 25 | SoundEvent event = new SoundEvent(new ResourceLocation(name)); 26 | event.setRegistryName(name); 27 | SOUNDS.add(event); 28 | return event; 29 | } 30 | 31 | @SubscribeEvent 32 | @SuppressWarnings("unused") 33 | public static void registerSounds(final RegistryEvent.Register event) 34 | { 35 | SOUNDS.forEach(soundEvent -> event.getRegistry().register(soundEvent)); 36 | SOUNDS.clear(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "itemGroup.improvedwolves": "Improved Wolves", 3 | "block.improvedwolves.dog_bowl": "Dog Bowl", 4 | "block.improvedwolves.white_dog_bowl": "White Dog Bowl", 5 | "block.improvedwolves.orange_dog_bowl": "Orange Dog Bowl", 6 | "block.improvedwolves.magenta_dog_bowl": "Magenta Dog Bowl", 7 | "block.improvedwolves.light_blue_dog_bowl": "Light Blue Dog Bowl", 8 | "block.improvedwolves.yellow_dog_bowl": "Yellow Dog Bowl", 9 | "block.improvedwolves.lime_dog_bowl": "Lime Dog Bowl", 10 | "block.improvedwolves.pink_dog_bowl": "Pink Dog Bowl", 11 | "block.improvedwolves.gray_dog_bowl": "Gray Dog Bowl", 12 | "block.improvedwolves.light_gray_dog_bowl": "Light Gray Dog Bowl", 13 | "block.improvedwolves.cyan_dog_bowl": "Cyan Dog Bowl", 14 | "block.improvedwolves.purple_dog_bowl": "Purple Dog Bowl", 15 | "block.improvedwolves.blue_dog_bowl": "Blue Dog Bowl", 16 | "block.improvedwolves.brown_dog_bowl": "Brown Dog Bowl", 17 | "block.improvedwolves.green_dog_bowl": "Green Dog Bowl", 18 | "block.improvedwolves.red_dog_bowl": "Red Dog Bowl", 19 | "block.improvedwolves.black_dog_bowl": "Black Dog Bowl", 20 | "container.improvedwolves.dog_bowl": "Dog Bowl", 21 | "subtitle.improvedwolves.entity.player.whistle": "Whistle", 22 | "info.improvedwolves.storage_full": "%s is full!", 23 | "key.categories.improvedwolves": "Improved Wolves", 24 | "key.improvedwolves.deposit": "Wolf Command Deposit" 25 | } -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/common/CommonEvents.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.common; 2 | 3 | import com.mrcrayfish.improvedwolves.common.entity.WolfHeldItemDataHandler; 4 | import com.mrcrayfish.improvedwolves.network.PacketHandler; 5 | import com.mrcrayfish.improvedwolves.network.message.MessageSyncHeldWolfItem; 6 | import net.minecraft.entity.passive.WolfEntity; 7 | import net.minecraft.entity.player.PlayerEntity; 8 | import net.minecraft.item.ItemStack; 9 | import net.minecraftforge.event.TickEvent; 10 | import net.minecraftforge.event.entity.EntityEvent; 11 | import net.minecraftforge.event.entity.player.PlayerEvent; 12 | import net.minecraftforge.eventbus.api.SubscribeEvent; 13 | import net.minecraftforge.fml.network.PacketDistributor; 14 | 15 | import java.util.Optional; 16 | 17 | /** 18 | * Author: MrCrayfish 19 | */ 20 | public class CommonEvents 21 | { 22 | @SubscribeEvent 23 | public void onStartTracking(PlayerEvent.StartTracking event) 24 | { 25 | if(event.getTarget() instanceof WolfEntity) 26 | { 27 | WolfEntity wolfEntity = (WolfEntity) event.getTarget(); 28 | WolfHeldItemDataHandler.IWolfHeldItem heldItem = WolfHeldItemDataHandler.getHandler(wolfEntity); 29 | if(heldItem != null) 30 | { 31 | PacketHandler.instance.send(PacketDistributor.TRACKING_ENTITY.with(() -> wolfEntity), new MessageSyncHeldWolfItem(wolfEntity.getEntityId(), heldItem.getItemStack())); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/network/PacketHandler.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.network; 2 | 3 | import com.mrcrayfish.improvedwolves.Reference; 4 | import com.mrcrayfish.improvedwolves.network.message.IMessage; 5 | import com.mrcrayfish.improvedwolves.network.message.MessageSyncHeldWolfItem; 6 | import com.mrcrayfish.improvedwolves.network.message.MessageWolfDepositItem; 7 | import net.minecraft.util.ResourceLocation; 8 | import net.minecraftforge.fml.network.NetworkRegistry; 9 | import net.minecraftforge.fml.network.simple.SimpleChannel; 10 | 11 | public class PacketHandler 12 | { 13 | public static final String PROTOCOL_VERSION = "1"; 14 | 15 | public static SimpleChannel instance; 16 | private static int nextId = 0; 17 | 18 | public static void register() 19 | { 20 | instance = NetworkRegistry.ChannelBuilder 21 | .named(new ResourceLocation(Reference.MOD_ID, "network")) 22 | .networkProtocolVersion(() -> PROTOCOL_VERSION) 23 | .clientAcceptedVersions(PROTOCOL_VERSION::equals) 24 | .serverAcceptedVersions(PROTOCOL_VERSION::equals) 25 | .simpleChannel(); 26 | 27 | register(MessageWolfDepositItem.class, new MessageWolfDepositItem()); 28 | register(MessageSyncHeldWolfItem.class, new MessageSyncHeldWolfItem()); 29 | } 30 | 31 | private static void register(Class clazz, IMessage message) 32 | { 33 | instance.registerMessage(nextId++, clazz, message::encode, message::decode, message::handle); 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/lang/de_de.json: -------------------------------------------------------------------------------- 1 | { 2 | "itemGroup.improvedwolves": "Verbesserte W\u00f6lfe", 3 | "block.improvedwolves.dog_bowl": "Hundenapf", 4 | "block.improvedwolves.white_dog_bowl": "Wei\u00dfer Hundenapf", 5 | "block.improvedwolves.orange_dog_bowl": "Oranger Hundenapf", 6 | "block.improvedwolves.magenta_dog_bowl": "Magenta Hundenapf", 7 | "block.improvedwolves.light_blue_dog_bowl": "Hellblauer Hundenapf", 8 | "block.improvedwolves.yellow_dog_bowl": "Gelber Hundenapf", 9 | "block.improvedwolves.lime_dog_bowl": "Hellgr\u00fcner Hundenapf", 10 | "block.improvedwolves.pink_dog_bowl": "Rosa Hundenapf", 11 | "block.improvedwolves.gray_dog_bowl": "Grauer Hundenapf", 12 | "block.improvedwolves.light_gray_dog_bowl": "Hellgrauer Hundenapf", 13 | "block.improvedwolves.cyan_dog_bowl": "T\u00fcrkiser Hundenapf", 14 | "block.improvedwolves.purple_dog_bowl": "Violetter Hundenapf", 15 | "block.improvedwolves.blue_dog_bowl": "Blauer Hundenapf", 16 | "block.improvedwolves.brown_dog_bowl": "Brauner Hundenapf", 17 | "block.improvedwolves.green_dog_bowl": "Gr\u00fcner Hundenapf", 18 | "block.improvedwolves.red_dog_bowl": "Roter Hundenapf", 19 | "block.improvedwolves.black_dog_bowl": "Schwarzer Hundenapf", 20 | "container.improvedwolves.dog_bowl": "Hundenapf", 21 | "subtitle.improvedwolves.entity.player.whistle": "Pfeifen", 22 | "info.improvedwolves.storage_full": "%s ist voll!", 23 | "key.categories.improvedwolves": "Verbesserte W\u00f6lfe", 24 | "key.improvedwolves.deposit": "Wolf Befehl Ablegen" 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/init/ModContainers.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.init; 2 | 3 | import com.mrcrayfish.improvedwolves.Reference; 4 | import com.mrcrayfish.improvedwolves.inventory.container.DogBowlContainer; 5 | import net.minecraft.inventory.container.Container; 6 | import net.minecraft.inventory.container.ContainerType; 7 | import net.minecraftforge.event.RegistryEvent; 8 | import net.minecraftforge.eventbus.api.SubscribeEvent; 9 | import net.minecraftforge.fml.common.Mod; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * Author: MrCrayfish 16 | */ 17 | @Mod.EventBusSubscriber(modid = Reference.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) 18 | public class ModContainers 19 | { 20 | private static final List> CONTAINER_TYPES = new ArrayList<>(); 21 | 22 | public static final ContainerType DOG_BOWL = register(Reference.MOD_ID + ":dog_bowl", DogBowlContainer::new); 23 | 24 | private static ContainerType register(String key, ContainerType.IFactory factory) 25 | { 26 | ContainerType type = new ContainerType<>(factory); 27 | type.setRegistryName(key); 28 | CONTAINER_TYPES.add(type); 29 | return type; 30 | } 31 | 32 | @SubscribeEvent 33 | @SuppressWarnings("unused") 34 | public static void registerTypes(final RegistryEvent.Register> event) 35 | { 36 | CONTAINER_TYPES.forEach(type -> event.getRegistry().register(type)); 37 | CONTAINER_TYPES.clear(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/init/ModMemoryModuleTypes.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.init; 2 | 3 | import com.mojang.datafixers.Dynamic; 4 | import com.mrcrayfish.improvedwolves.Reference; 5 | import net.minecraft.entity.ai.brain.memory.MemoryModuleType; 6 | import net.minecraft.util.math.GlobalPos; 7 | import net.minecraftforge.event.RegistryEvent; 8 | import net.minecraftforge.eventbus.api.SubscribeEvent; 9 | import net.minecraftforge.fml.common.Mod; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.Optional; 14 | import java.util.function.Function; 15 | 16 | /** 17 | * Author: MrCrayfish 18 | */ 19 | @Mod.EventBusSubscriber(modid = Reference.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) 20 | public class ModMemoryModuleTypes 21 | { 22 | private static final List> MODULES = new ArrayList<>(); 23 | 24 | public static final MemoryModuleType CHEST = register(Reference.MOD_ID + ":chest", GlobalPos::deserialize); 25 | 26 | private static MemoryModuleType register(String key, Function, U> function) 27 | { 28 | MemoryModuleType module = new MemoryModuleType<>(Optional.of(function)); 29 | module.setRegistryName(key); 30 | MODULES.add(module); 31 | return module; 32 | } 33 | 34 | @SubscribeEvent 35 | @SuppressWarnings("unused") 36 | public static void registerTypes(final RegistryEvent.Register> event) 37 | { 38 | MODULES.forEach(type -> event.getRegistry().register(type)); 39 | MODULES.clear(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/network/message/MessageSyncHeldWolfItem.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.network.message; 2 | 3 | import com.mrcrayfish.improvedwolves.client.ClientHandler; 4 | import com.mrcrayfish.improvedwolves.common.entity.WolfHeldItemDataHandler; 5 | import net.minecraft.entity.Entity; 6 | import net.minecraft.entity.passive.WolfEntity; 7 | import net.minecraft.entity.player.ServerPlayerEntity; 8 | import net.minecraft.item.ItemStack; 9 | import net.minecraft.network.PacketBuffer; 10 | import net.minecraftforge.fml.network.NetworkEvent; 11 | 12 | import java.util.function.Supplier; 13 | 14 | /** 15 | * Author: MrCrayfish 16 | */ 17 | public class MessageSyncHeldWolfItem implements IMessage 18 | { 19 | private int entityId; 20 | private ItemStack stack; 21 | 22 | public MessageSyncHeldWolfItem() {} 23 | 24 | public MessageSyncHeldWolfItem(int entityId, ItemStack stack) 25 | { 26 | this.entityId = entityId; 27 | this.stack = stack; 28 | } 29 | 30 | @Override 31 | public void encode(MessageSyncHeldWolfItem message, PacketBuffer buffer) 32 | { 33 | buffer.writeVarInt(message.entityId); 34 | buffer.writeItemStack(message.stack); 35 | } 36 | 37 | @Override 38 | public MessageSyncHeldWolfItem decode(PacketBuffer buffer) 39 | { 40 | return new MessageSyncHeldWolfItem(buffer.readVarInt(), buffer.readItemStack()); 41 | } 42 | 43 | @Override 44 | public void handle(MessageSyncHeldWolfItem message, Supplier supplier) 45 | { 46 | supplier.get().enqueueWork(() -> ClientHandler.setWolfHeldItem(message.entityId, message.stack)); 47 | supplier.get().setPacketHandled(true); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/client/screen/DogBowlScreen.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.client.screen; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import com.mrcrayfish.improvedwolves.inventory.container.DogBowlContainer; 5 | import net.minecraft.client.gui.screen.inventory.ContainerScreen; 6 | import net.minecraft.entity.player.PlayerInventory; 7 | import net.minecraft.util.ResourceLocation; 8 | import net.minecraft.util.text.ITextComponent; 9 | 10 | /** 11 | * Author: MrCrayfish 12 | */ 13 | public class DogBowlScreen extends ContainerScreen 14 | { 15 | private static final ResourceLocation GUI_TEXTURE = new ResourceLocation("improvedwolves:textures/gui/container/dog_bowl.png"); 16 | 17 | public DogBowlScreen(DogBowlContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) 18 | { 19 | super(screenContainer, inv, titleIn); 20 | this.xSize = 176; 21 | this.ySize = 133; 22 | } 23 | 24 | @Override 25 | public void render(int mouseX, int mouseY, float partialTicks) 26 | { 27 | this.renderBackground(); 28 | super.render(mouseX, mouseY, partialTicks); 29 | this.renderHoveredToolTip(mouseX, mouseY); 30 | } 31 | 32 | @Override 33 | protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) 34 | { 35 | RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); 36 | this.minecraft.getTextureManager().bindTexture(GUI_TEXTURE); 37 | this.blit(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); 38 | } 39 | 40 | @Override 41 | protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) 42 | { 43 | String title = this.title.getFormattedText(); 44 | this.font.drawString(title, (float)(this.xSize / 2 - this.font.getStringWidth(title) / 2), 6.0F, 4210752); 45 | this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8.0F, (float)(this.ySize - 96 + 2), 4210752); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/init/ModTileEntities.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.init; 2 | 3 | import com.mrcrayfish.improvedwolves.Reference; 4 | import com.mrcrayfish.improvedwolves.tileentity.DogBowlTileEntity; 5 | import net.minecraft.tileentity.TileEntity; 6 | import net.minecraft.tileentity.TileEntityType; 7 | import net.minecraftforge.event.RegistryEvent; 8 | import net.minecraftforge.eventbus.api.SubscribeEvent; 9 | import net.minecraftforge.fml.common.Mod; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * Author: MrCrayfish 16 | */ 17 | @Mod.EventBusSubscriber(modid = Reference.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) 18 | public class ModTileEntities 19 | { 20 | private static final List TILE_ENTITY_TYPES = new ArrayList<>(); 21 | 22 | public static final TileEntityType DOG_BOWL = buildType(Reference.MOD_ID + ":dog_bowl", TileEntityType.Builder.create(DogBowlTileEntity::new, ModBlocks.WHITE_DOG_BOWL, ModBlocks.ORANGE_DOG_BOWL, ModBlocks.MAGENTA_DOG_BOWL, ModBlocks.LIGHT_BLUE_DOG_BOWL, ModBlocks.YELLOW_DOG_BOWL, ModBlocks.LIME_DOG_BOWL, ModBlocks.PINK_DOG_BOWL, ModBlocks.GRAY_DOG_BOWL, ModBlocks.LIGHT_GRAY_DOG_BOWL, ModBlocks.CYAN_DOG_BOWL, ModBlocks.PURPLE_DOG_BOWL, ModBlocks.BLUE_DOG_BOWL, ModBlocks.BROWN_DOG_BOWL, ModBlocks.GREEN_DOG_BOWL, ModBlocks.RED_DOG_BOWL, ModBlocks.BLACK_DOG_BOWL)); 23 | 24 | private static TileEntityType buildType(String id, TileEntityType.Builder builder) 25 | { 26 | TileEntityType type = builder.build(null); //TODO may not allow null 27 | type.setRegistryName(id); 28 | TILE_ENTITY_TYPES.add(type); 29 | return type; 30 | } 31 | 32 | @SubscribeEvent 33 | @SuppressWarnings("unused") 34 | public static void registerTypes(final RegistryEvent.Register> event) 35 | { 36 | TILE_ENTITY_TYPES.forEach(type -> event.getRegistry().register(type)); 37 | TILE_ENTITY_TYPES.clear(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/util/TileEntityUtil.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.util; 2 | 3 | import net.minecraft.entity.player.ServerPlayerEntity; 4 | import net.minecraft.nbt.CompoundNBT; 5 | import net.minecraft.network.play.server.SUpdateTileEntityPacket; 6 | import net.minecraft.tileentity.TileEntity; 7 | import net.minecraft.util.math.BlockPos; 8 | import net.minecraft.util.math.ChunkPos; 9 | import net.minecraft.world.World; 10 | import net.minecraft.world.server.ServerWorld; 11 | 12 | import java.util.stream.Stream; 13 | 14 | /** 15 | * Author: MrCrayfish 16 | */ 17 | public class TileEntityUtil 18 | { 19 | /** 20 | * Sends an update packet to clients tracking a tile entity. 21 | * 22 | * @param tileEntity the tile entity to update 23 | */ 24 | public static void sendUpdatePacket(TileEntity tileEntity) 25 | { 26 | SUpdateTileEntityPacket packet = tileEntity.getUpdatePacket(); 27 | if(packet != null) 28 | { 29 | sendUpdatePacket(tileEntity.getWorld(), tileEntity.getPos(), packet); 30 | } 31 | } 32 | 33 | /** 34 | * Sends an update packet to clients tracking a tile entity with a specific CompoundNBT 35 | * 36 | * @param tileEntity the tile entity to update 37 | */ 38 | public static void sendUpdatePacket(TileEntity tileEntity, CompoundNBT compound) 39 | { 40 | SUpdateTileEntityPacket packet = new SUpdateTileEntityPacket(tileEntity.getPos(), 0, compound); 41 | sendUpdatePacket(tileEntity.getWorld(), tileEntity.getPos(), packet); 42 | } 43 | 44 | private static void sendUpdatePacket(World world, BlockPos pos, SUpdateTileEntityPacket packet) 45 | { 46 | if(world instanceof ServerWorld) 47 | { 48 | ServerWorld server = (ServerWorld) world; 49 | Stream players = server.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(pos), false); 50 | players.forEach(player -> player.connection.sendPacket(packet)); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/lang/en_ud.json: -------------------------------------------------------------------------------- 1 | { 2 | "itemGroup.improvedwolves": "s\u01dd\u028c\ua781oM p\u01dd\u028co\u0279d\u026fI", 3 | "block.improvedwolves.dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1", 4 | "block.improvedwolves.white_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u01dd\u0287\u1d09\u0265M", 5 | "block.improvedwolves.orange_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u01dd\u1d77u\u0250\u0279O", 6 | "block.improvedwolves.magenta_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u0250\u0287u\u01dd\u1d77\u0250W", 7 | "block.improvedwolves.light_blue_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u01ddn\ua781\u15fa \u0287\u0265\u1d77\u1d09\ua780", 8 | "block.improvedwolves.yellow_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u028do\ua781\ua781\u01dd\u2144", 9 | "block.improvedwolves.lime_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u01dd\u026f\u1d09\ua780", 10 | "block.improvedwolves.pink_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u029eu\u1d09\u0500", 11 | "block.improvedwolves.gray_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u028e\u0250\u0279\u2141", 12 | "block.improvedwolves.light_gray_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u028e\u0250\u0279\u2141 \u0287\u0265\u1d77\u1d09\ua780", 13 | "block.improvedwolves.cyan_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 u\u0250\u028e\u0186", 14 | "block.improvedwolves.purple_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u01dd\ua781d\u0279n\u0500", 15 | "block.improvedwolves.blue_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u01ddn\ua781\u15fa", 16 | "block.improvedwolves.brown_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 u\u028do\u0279\u15fa", 17 | "block.improvedwolves.green_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 u\u01dd\u01dd\u0279\u2141", 18 | "block.improvedwolves.red_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 p\u01dd\u1d1a", 19 | "block.improvedwolves.black_dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1 \u029e\u0254\u0250\ua781\u15fa", 20 | "container.improvedwolves.dog_bowl": "\ua781\u028do\u15fa \u1d77o\u15e1", 21 | "subtitle.improvedwolves.entity.player.whistle": "\u01dd\ua781\u0287s\u1d09\u0265M", 22 | "info.improvedwolves.storage_full": "i\ua781\ua781n\u025f s\u1d09 %s", 23 | "key.categories.improvedwolves": "s\u01dd\u028c\ua781oM p\u01dd\u028co\u0279d\u026fI", 24 | "key.improvedwolves.deposit": "\u0287\u1d09sod\u01dd\u15e1 pu\u0250\u026f\u026fo\u0186 \u025f\ua781oM" 25 | } 26 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------- 2 | Source installation information for modders 3 | ------------------------------------------- 4 | This code follows the Minecraft Forge installation methodology. It will apply 5 | some small patches to the vanilla MCP source code, giving you and it access 6 | to some of the data and functions you need to build a successful mod. 7 | 8 | Note also that the patches are built against "unrenamed" MCP source code (aka 9 | srgnames) - this means that you will not be able to read them directly against 10 | normal code. 11 | 12 | Source pack installation information: 13 | 14 | Standalone source installation 15 | ============================== 16 | 17 | See the Forge Documentation online for more detailed instructions: 18 | http://mcforge.readthedocs.io/en/latest/gettingstarted/ 19 | 20 | Step 1: Open your command-line and browse to the folder where you extracted the zip file. 21 | 22 | Step 2: You're left with a choice. 23 | If you prefer to use Eclipse: 24 | 1. Run the following command: "gradlew genEclipseRuns" (./gradlew genEclipseRuns if you are on Mac/Linux) 25 | 2. Open Eclipse, Import > Existing Gradle Project > Select Folder 26 | or run "gradlew eclipse" to generate the project. 27 | (Current Issue) 28 | 4. Open Project > Run/Debug Settings > Edit runClient and runServer > Environment 29 | 5. Edit MOD_CLASSES to show [modid]%%[Path]; 2 times rather then the generated 4. 30 | 31 | If you prefer to use IntelliJ: 32 | 1. Open IDEA, and import project. 33 | 2. Select your build.gradle file and have it import. 34 | 3. Run the following command: "gradlew genIntellijRuns" (./gradlew genIntellijRuns if you are on Mac/Linux) 35 | 4. Refresh the Gradle Project in IDEA if required. 36 | 37 | If at any point you are missing libraries in your IDE, or you've run into problems you can run "gradlew --refresh-dependencies" to refresh the local cache. "gradlew clean" to reset everything {this does not affect your code} and then start the processs again. 38 | 39 | Should it still not work, 40 | Refer to #ForgeGradle on EsperNet for more information about the gradle environment. 41 | or the Forge Project Discord discord.gg/UvedJ9m 42 | 43 | Forge source installation 44 | ========================= 45 | MinecraftForge ships with this code and installs it as part of the forge 46 | installation process, no further action is required on your part. 47 | 48 | LexManos' Install Video 49 | ======================= 50 | https://www.youtube.com/watch?v=8VEdtQLuLO0&feature=youtu.be 51 | 52 | For more details update more often refer to the Forge Forums: 53 | http://www.minecraftforge.net/forum/index.php/topic,14048.0.html 54 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/tileentity/DogBowlTileEntity.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.tileentity; 2 | 3 | import com.mrcrayfish.improvedwolves.init.ModTileEntities; 4 | import com.mrcrayfish.improvedwolves.inventory.container.DogBowlContainer; 5 | import com.mrcrayfish.improvedwolves.util.TileEntityUtil; 6 | import net.minecraft.entity.player.PlayerInventory; 7 | import net.minecraft.inventory.container.Container; 8 | import net.minecraft.item.Food; 9 | import net.minecraft.item.ItemStack; 10 | import net.minecraft.nbt.CompoundNBT; 11 | import net.minecraft.network.NetworkManager; 12 | import net.minecraft.network.play.server.SUpdateTileEntityPacket; 13 | import net.minecraft.util.text.ITextComponent; 14 | import net.minecraft.util.text.TranslationTextComponent; 15 | 16 | import javax.annotation.Nullable; 17 | 18 | /** 19 | * Author: MrCrayfish 20 | */ 21 | public class DogBowlTileEntity extends BasicLootTileEntity 22 | { 23 | public DogBowlTileEntity() 24 | { 25 | super(ModTileEntities.DOG_BOWL); 26 | } 27 | 28 | @Override 29 | public int getSizeInventory() 30 | { 31 | return 1; 32 | } 33 | 34 | @Override 35 | protected ITextComponent getDefaultName() 36 | { 37 | return new TranslationTextComponent("container.improvedwolves.dog_bowl"); 38 | } 39 | 40 | @Override 41 | protected Container createMenu(int windowId, PlayerInventory playerInventory) 42 | { 43 | return new DogBowlContainer(windowId, playerInventory, this); 44 | } 45 | 46 | @Override 47 | public CompoundNBT getUpdateTag() 48 | { 49 | return this.write(new CompoundNBT()); 50 | } 51 | 52 | @Nullable 53 | @Override 54 | public SUpdateTileEntityPacket getUpdatePacket() 55 | { 56 | return new SUpdateTileEntityPacket(this.pos, 0, this.getUpdateTag()); 57 | } 58 | 59 | @Override 60 | public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) 61 | { 62 | this.read(pkt.getNbtCompound()); 63 | } 64 | 65 | public boolean hasFood() 66 | { 67 | ItemStack stack = this.getStackInSlot(0); 68 | return !stack.isEmpty() && stack.getItem().getFood() != null; 69 | } 70 | 71 | @Nullable 72 | public Food getFood() 73 | { 74 | ItemStack stack = this.getStackInSlot(0); 75 | if(!stack.isEmpty()) 76 | { 77 | return stack.getItem().getFood(); 78 | } 79 | return null; 80 | } 81 | 82 | public void consumeFood() 83 | { 84 | ItemStack stack = this.getStackInSlot(0); 85 | if(!stack.isEmpty()) 86 | { 87 | stack.shrink(1); 88 | TileEntityUtil.sendUpdatePacket(this); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/resources/assets/improvedwolves/models/block/dog_bowl.json: -------------------------------------------------------------------------------- 1 | { 2 | "credit": "Model by MrCrayfish (https://twitter.com/MrCraayfish) using Blockbench", 3 | "textures": { 4 | "texture": "improvedwolves:block/dog_bowl", 5 | "particle": "improvedwolves:block/dog_bowl" 6 | }, 7 | "display": { 8 | "gui": { 9 | "rotation": [ 30, 45, 0 ], 10 | "translation": [ 0, 5, 0 ], 11 | "scale": [ 1, 1, 1 ] 12 | }, 13 | "ground": { 14 | "rotation": [ 0, 0, 0 ], 15 | "translation": [ 0, 3, 0 ], 16 | "scale": [ 0.5, 0.5, 0.5 ] 17 | }, 18 | "fixed": { 19 | "rotation": [ 0, 180, 0 ], 20 | "translation": [ 0, 0, 0 ], 21 | "scale": [ 1, 1, 1 ] 22 | }, 23 | "head": { 24 | "rotation": [ 0, 180, 0 ], 25 | "translation": [ 0, 8, 0 ], 26 | "scale": [ 1, 1, 1 ] 27 | }, 28 | "firstperson_righthand": { 29 | "rotation": [ 0, 315, 0 ], 30 | "translation": [ 0, 5.5, 0 ], 31 | "scale": [ 0.6, 0.6, 0.6 ] 32 | }, 33 | "thirdperson_righthand": { 34 | "rotation": [ 75, 315, 0 ], 35 | "translation": [ 0, 3, 3 ], 36 | "scale": [ 0.5, 0.5, 0.5 ] 37 | } 38 | }, 39 | "elements": [ 40 | { 41 | "from": [3, 0, 3], 42 | "to": [13, 1, 13], 43 | "faces": { 44 | "north": {"uv": [5, 4.5, 10, 5], "texture": "#texture"}, 45 | "east": {"uv": [5, 6.5, 10, 7], "texture": "#texture"}, 46 | "south": {"uv": [5, 7, 10, 7.5], "texture": "#texture"}, 47 | "west": {"uv": [5, 7.5, 10, 8], "texture": "#texture"}, 48 | "up": {"uv": [0, 0, 5, 5], "texture": "#texture"}, 49 | "down": {"uv": [0, 5, 5, 10], "texture": "#texture"} 50 | } 51 | }, 52 | { 53 | "from": [3, 1, 12], 54 | "to": [13, 4, 13], 55 | "faces": { 56 | "north": {"uv": [5, 0, 10, 1.5], "texture": "#texture"}, 57 | "east": {"uv": [6.5, 9, 7, 10.5], "texture": "#texture", "tintindex": 0}, 58 | "south": {"uv": [5, 5, 10, 6.5], "texture": "#texture", "tintindex": 0}, 59 | "west": {"uv": [6, 9, 6.5, 10.5], "texture": "#texture", "tintindex": 0}, 60 | "up": {"uv": [5, 8, 10, 8.5], "rotation": 180, "texture": "#texture", "tintindex": 0} 61 | } 62 | }, 63 | { 64 | "from": [3, 1, 3], 65 | "to": [13, 4, 4], 66 | "faces": { 67 | "north": {"uv": [5, 5, 10, 6.5], "texture": "#texture", "tintindex": 0}, 68 | "east": {"uv": [6, 9, 6.5, 10.5], "texture": "#texture", "tintindex": 0}, 69 | "south": {"uv": [5, 0, 10, 1.5], "texture": "#texture"}, 70 | "west": {"uv": [6.5, 9, 7, 10.5], "texture": "#texture", "tintindex": 0}, 71 | "up": {"uv": [5, 8, 10, 8.5], "texture": "#texture", "tintindex": 0} 72 | } 73 | }, 74 | { 75 | "from": [12, 1, 4], 76 | "to": [13, 4, 12], 77 | "faces": { 78 | "east": {"uv": [5, 3, 9, 4.5], "texture": "#texture", "tintindex": 0}, 79 | "west": {"uv": [5, 1.5, 9, 3], "texture": "#texture"}, 80 | "up": {"uv": [5, 9, 5.5, 13], "rotation": 180, "texture": "#texture", "tintindex": 0} 81 | } 82 | }, 83 | { 84 | "from": [3, 1, 4], 85 | "to": [4, 4, 12], 86 | "faces": { 87 | "east": {"uv": [5, 1.5, 9, 3], "texture": "#texture"}, 88 | "west": {"uv": [5, 3, 9, 4.5], "texture": "#texture", "tintindex": 0}, 89 | "up": {"uv": [5, 9, 5.5, 13], "texture": "#texture", "tintindex": 0} 90 | } 91 | } 92 | ] 93 | } -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/client/render/tileentity/DogBowlRenderer.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.client.render.tileentity; 2 | 3 | import com.mojang.blaze3d.matrix.MatrixStack; 4 | import com.mrcrayfish.improvedwolves.block.DogBowlBlock; 5 | import com.mrcrayfish.improvedwolves.tileentity.DogBowlTileEntity; 6 | import net.minecraft.block.BlockState; 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.client.renderer.IRenderTypeBuffer; 9 | import net.minecraft.client.renderer.Vector3f; 10 | import net.minecraft.client.renderer.model.ItemCameraTransforms; 11 | import net.minecraft.client.renderer.tileentity.TileEntityRenderer; 12 | import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; 13 | import net.minecraft.item.ItemStack; 14 | import net.minecraft.util.Direction; 15 | 16 | /** 17 | * Author: MrCrayfish 18 | */ 19 | public class DogBowlRenderer extends TileEntityRenderer 20 | { 21 | public DogBowlRenderer(TileEntityRendererDispatcher rendererDispatcherIn) 22 | { 23 | super(rendererDispatcherIn); 24 | } 25 | 26 | @Override 27 | public void render(DogBowlTileEntity tileEntityIn, float partialTicks, MatrixStack stack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) 28 | { 29 | BlockState state = tileEntityIn.getBlockState(); 30 | if(!state.has(DogBowlBlock.HORIZONTAL_FACING)) 31 | return; 32 | 33 | ItemStack itemStack = tileEntityIn.getStackInSlot(0); 34 | if(!itemStack.isEmpty()) 35 | { 36 | int count = (int) Math.ceil(itemStack.getCount() / 16.0); 37 | for(int i = 0; i < count; i++) 38 | { 39 | stack.push(); 40 | stack.translate(0.5, 0.1, 0.5); 41 | stack.translate(0, i * 0.03125, 0); 42 | Direction direction = state.get(DogBowlBlock.HORIZONTAL_FACING); 43 | stack.rotate(Vector3f.YP.rotationDegrees(-direction.getHorizontalAngle())); 44 | stack.rotate(Vector3f.YP.rotationDegrees(i * 90F)); 45 | stack.rotate(Vector3f.XP.rotationDegrees(90.0F)); 46 | stack.scale(0.5F, 0.5F, 0.5F); 47 | stack.scale(1.0F, 1.0F, 1.5F); 48 | Minecraft.getInstance().getItemRenderer().renderItem(itemStack, ItemCameraTransforms.TransformType.FIXED, combinedLightIn, combinedOverlayIn, stack, buffer); 49 | stack.pop(); 50 | } 51 | } 52 | 53 | if(tileEntityIn.hasCustomName()) 54 | { 55 | stack.push(); 56 | stack.translate(0.5, 0, 0.5); 57 | Direction direction = state.get(DogBowlBlock.HORIZONTAL_FACING); 58 | stack.rotate(Vector3f.YP.rotationDegrees(-direction.getHorizontalAngle())); 59 | stack.translate(0, 0.145, -0.3125 - 0.001); 60 | stack.scale(-1, -1, 0); 61 | String text = tileEntityIn.getDisplayName().getFormattedText(); 62 | int width = this.renderDispatcher.fontRenderer.getStringWidth(text); 63 | float scale = 0.4375F / width; 64 | stack.scale(scale, scale, scale); 65 | stack.translate(-width / 2.0, -4.5, 0); 66 | this.renderDispatcher.fontRenderer.renderString(text, 0, 0, 0xFFFFFF, false, stack.getLast().getPositionMatrix(), buffer, false, 0, combinedLightIn); 67 | stack.pop(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /CREDITS.txt: -------------------------------------------------------------------------------- 1 | Minecraft Forge: Credits/Thank You 2 | 3 | Forge is a set of tools and modifications to the Minecraft base game code to assist 4 | mod developers in creating new and exciting content. It has been in development for 5 | several years now, but I would like to take this time thank a few people who have 6 | helped it along it's way. 7 | 8 | First, the people who originally created the Forge projects way back in Minecraft 9 | alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance 10 | of me taking over the project, who knows what Minecraft modding would be today. 11 | 12 | Secondly, someone who has worked with me, and developed some of the core features 13 | that allow modding to be as functional, and as simple as it is, cpw. For developing 14 | FML, which stabelized the client and server modding ecosystem. As well as the base 15 | loading system that allows us to modify Minecraft's code as elegently as possible. 16 | 17 | Mezz, who has stepped up as the issue and pull request manager. Helping to keep me 18 | sane as well as guiding the community into creating better additions to Forge. 19 | 20 | Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which 21 | I am a part}. For creating some of the core tools needed to make Minecraft modding 22 | both possible, and as stable as can be. 23 | On that note, here is some specific information of the MCP data we use: 24 | * Minecraft Coder Pack (MCP) * 25 | Forge Mod Loader and Minecraft Forge have permission to distribute and automatically 26 | download components of MCP and distribute MCP data files. This permission is not 27 | transitive and others wishing to redistribute the Minecraft Forge source independently 28 | should seek permission of MCP or remove the MCP data files and request their users 29 | to download MCP separately. 30 | 31 | And lastly, the countless community members who have spent time submitting bug reports, 32 | pull requests, and just helping out the community in general. Thank you. 33 | 34 | --LexManos 35 | 36 | ========================================================================= 37 | 38 | This is Forge Mod Loader. 39 | 40 | You can find the source code at all times at https://github.com/MinecraftForge/MinecraftForge/tree/1.12.x/src/main/java/net/minecraftforge/fml 41 | 42 | This minecraft mod is a clean open source implementation of a mod loader for minecraft servers 43 | and minecraft clients. 44 | 45 | The code is authored by cpw. 46 | 47 | It began by partially implementing an API defined by the client side ModLoader, authored by Risugami. 48 | http://www.minecraftforum.net/topic/75440- 49 | This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader. 50 | 51 | It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge. 52 | http://www.minecraftforge.net/ 53 | 54 | Additionally, it contains an implementation of topological sort based on that 55 | published at http://keithschwarz.com/interesting/code/?dir=topological-sort 56 | 57 | It also contains code from the Maven project for performing versioned dependency 58 | resolution. http://maven.apache.org/ 59 | 60 | It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/ 61 | with credit to it's authors. 62 | 63 | Forge Mod Loader downloads components from the Minecraft Coder Pack 64 | (http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team. 65 | 66 | -------------------------------------------------------------------------------- /src/main/resources/coremods/goal-hook.js: -------------------------------------------------------------------------------- 1 | function initializeCoreMod() { 2 | return { 3 | 'goal_hook': { 4 | 'target': { 5 | 'type': 'METHOD', 6 | 'class': 'net.minecraft.entity.MobEntity', 7 | 'methodName': '', 8 | 'methodDesc': '(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V' 9 | }, 10 | 'transformer': function(method) { 11 | patch_MobEntity_Init(method); 12 | return method; 13 | } 14 | }, 15 | 'brain_hook': { 16 | 'target': { 17 | 'type': 'METHOD', 18 | 'class': 'net.minecraft.entity.LivingEntity', 19 | 'methodName': 'func_213364_a', 20 | 'methodDesc': '(Lcom/mojang/datafixers/Dynamic;)Lnet/minecraft/entity/ai/brain/Brain;' 21 | }, 22 | 'transformer': function(method) { 23 | patch_LivingEntity_createBrain(method); 24 | return method; 25 | } 26 | } 27 | }; 28 | } 29 | 30 | var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI'); 31 | var Opcodes = Java.type('org.objectweb.asm.Opcodes'); 32 | var MethodInsnNode = Java.type('org.objectweb.asm.tree.MethodInsnNode'); 33 | var InsnNode = Java.type('org.objectweb.asm.tree.InsnNode'); 34 | var VarInsnNode = Java.type('org.objectweb.asm.tree.VarInsnNode'); 35 | var IntInsnNode = Java.type('org.objectweb.asm.tree.IntInsnNode'); 36 | var LabelNode = Java.type('org.objectweb.asm.tree.LabelNode'); 37 | var FieldInsnNode = Java.type('org.objectweb.asm.tree.FieldInsnNode'); 38 | var TypeInsnNode = Java.type('org.objectweb.asm.tree.TypeInsnNode'); 39 | var JumpInsnNode = Java.type('org.objectweb.asm.tree.JumpInsnNode'); 40 | var FrameNode = Java.type('org.objectweb.asm.tree.FrameNode'); 41 | 42 | function patch_MobEntity_Init(method) { 43 | var foundNode = null; 44 | var instructions = method.instructions.toArray(); 45 | var length = instructions.length; 46 | for (var i = 0; i < length; i++) { 47 | var node = instructions[i]; 48 | if(node.getOpcode() == Opcodes.INVOKEVIRTUAL && node.name.equals(ASMAPI.mapMethod("func_184651_r"))) { 49 | foundNode = node; 50 | break; 51 | } 52 | } 53 | if(foundNode !== null) { 54 | method.instructions.insert(foundNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/mrcrayfish/improvedwolves/ImprovedWolves", "registerGoals", "(Lnet/minecraft/entity/MobEntity;)V", false)); 55 | method.instructions.insert(foundNode, new VarInsnNode(Opcodes.ALOAD, 0)); 56 | print("[Improved Wolves] Patched registerGoals"); 57 | } 58 | } 59 | 60 | function patch_LivingEntity_createBrain(method) { 61 | var foundNode = null; 62 | var instructions = method.instructions.toArray(); 63 | var length = instructions.length; 64 | for (var i = 0; i < length; i++) { 65 | var node = instructions[i]; 66 | if(node.getOpcode() == Opcodes.NEW && node.desc.equals("net/minecraft/entity/ai/brain/Brain")) { 67 | foundNode = node; 68 | break; 69 | } 70 | } 71 | if(foundNode !== null) { 72 | removeNthNodes(method.instructions, foundNode, 5); 73 | method.instructions.insert(foundNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/mrcrayfish/improvedwolves/ImprovedWolves", "createBrain", "(Lnet/minecraft/entity/LivingEntity;Lcom/mojang/datafixers/Dynamic;)Lnet/minecraft/entity/ai/brain/Brain;", false)); 74 | method.instructions.insert(foundNode, new VarInsnNode(Opcodes.ALOAD, 1)); 75 | method.instructions.insert(foundNode, new VarInsnNode(Opcodes.ALOAD, 0)); 76 | method.instructions.remove(foundNode); 77 | } 78 | } 79 | 80 | function removeNthNodes(instructions, node, n) { 81 | while(n > 0) { 82 | if(node.getNext() === null) 83 | return false; 84 | instructions.remove(node.getNext()); 85 | n--; 86 | } 87 | while(n < 0) { 88 | if(node.getPrevious() === null) 89 | return false; 90 | instructions.remove(node.getPrevious()); 91 | n++; 92 | } 93 | return true; 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/ImprovedWolves.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves; 2 | 3 | import com.google.common.collect.ImmutableList; 4 | import com.mojang.datafixers.Dynamic; 5 | import com.mrcrayfish.improvedwolves.block.DogBowlBlock; 6 | import com.mrcrayfish.improvedwolves.client.ClientHandler; 7 | import com.mrcrayfish.improvedwolves.client.render.tileentity.DogBowlRenderer; 8 | import com.mrcrayfish.improvedwolves.client.screen.DogBowlScreen; 9 | import com.mrcrayfish.improvedwolves.common.CommonEvents; 10 | import com.mrcrayfish.improvedwolves.common.entity.PlayerDataHandler; 11 | import com.mrcrayfish.improvedwolves.common.entity.WolfHeldItemDataHandler; 12 | import com.mrcrayfish.improvedwolves.entity.ai.goal.MoveToDogBowlGoal; 13 | import com.mrcrayfish.improvedwolves.entity.ai.goal.PutInChestGoal; 14 | import com.mrcrayfish.improvedwolves.init.ModBlocks; 15 | import com.mrcrayfish.improvedwolves.init.ModContainers; 16 | import com.mrcrayfish.improvedwolves.init.ModMemoryModuleTypes; 17 | import com.mrcrayfish.improvedwolves.init.ModTileEntities; 18 | import com.mrcrayfish.improvedwolves.network.PacketHandler; 19 | import com.mrcrayfish.improvedwolves.tileentity.DogBowlTileEntity; 20 | import net.minecraft.block.Block; 21 | import net.minecraft.client.Minecraft; 22 | import net.minecraft.client.gui.ScreenManager; 23 | import net.minecraft.entity.LivingEntity; 24 | import net.minecraft.entity.MobEntity; 25 | import net.minecraft.entity.ai.brain.Brain; 26 | import net.minecraft.entity.passive.WolfEntity; 27 | import net.minecraft.item.ItemGroup; 28 | import net.minecraft.item.ItemStack; 29 | import net.minecraft.nbt.CompoundNBT; 30 | import net.minecraft.nbt.NBTDynamicOps; 31 | import net.minecraft.tileentity.TileEntity; 32 | import net.minecraftforge.common.MinecraftForge; 33 | import net.minecraftforge.common.util.Constants; 34 | import net.minecraftforge.fml.client.registry.ClientRegistry; 35 | import net.minecraftforge.fml.common.Mod; 36 | import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; 37 | import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; 38 | import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; 39 | 40 | /** 41 | * Author: MrCrayfish 42 | */ 43 | @Mod(Reference.MOD_ID) 44 | public class ImprovedWolves 45 | { 46 | public static final ItemGroup GROUP = new ItemGroup(Reference.MOD_ID) 47 | { 48 | @Override 49 | public ItemStack createIcon() 50 | { 51 | return new ItemStack(ModBlocks.RED_DOG_BOWL); 52 | } 53 | }; 54 | 55 | public ImprovedWolves() 56 | { 57 | FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); 58 | FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup); 59 | } 60 | 61 | private void onCommonSetup(FMLCommonSetupEvent event) 62 | { 63 | MinecraftForge.EVENT_BUS.register(new CommonEvents()); 64 | WolfHeldItemDataHandler.register(); 65 | PlayerDataHandler.register(); 66 | PacketHandler.register(); 67 | } 68 | 69 | private void onClientSetup(FMLClientSetupEvent event) 70 | { 71 | ClientHandler.setup(); 72 | } 73 | 74 | /* Linked via ASM in MobEntity */ 75 | @SuppressWarnings("unused") 76 | public static void registerGoals(MobEntity entity) 77 | { 78 | if(entity instanceof WolfEntity) 79 | { 80 | WolfEntity wolfEntity = (WolfEntity) entity; 81 | wolfEntity.goalSelector.addGoal(5, new MoveToDogBowlGoal(wolfEntity)); 82 | wolfEntity.goalSelector.addGoal(5, new PutInChestGoal(wolfEntity)); 83 | } 84 | } 85 | 86 | /* Linked via ASM in LivingEntity */ 87 | @SuppressWarnings("unused") 88 | public static Brain createBrain(LivingEntity entity, Dynamic dynamic) 89 | { 90 | if(entity instanceof WolfEntity) 91 | { 92 | return new Brain<>(ImmutableList.of(ModMemoryModuleTypes.CHEST), ImmutableList.of(), dynamic); 93 | } 94 | return new Brain<>(ImmutableList.of(), ImmutableList.of(), dynamic); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/inventory/container/DogBowlContainer.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.inventory.container; 2 | 3 | import com.mrcrayfish.improvedwolves.init.ModContainers; 4 | import com.mrcrayfish.improvedwolves.tileentity.DogBowlTileEntity; 5 | import com.mrcrayfish.improvedwolves.util.TileEntityUtil; 6 | import net.minecraft.entity.player.PlayerEntity; 7 | import net.minecraft.entity.player.PlayerInventory; 8 | import net.minecraft.inventory.IInventory; 9 | import net.minecraft.inventory.Inventory; 10 | import net.minecraft.inventory.container.Container; 11 | import net.minecraft.inventory.container.IContainerListener; 12 | import net.minecraft.inventory.container.Slot; 13 | import net.minecraft.item.ItemStack; 14 | import net.minecraft.tileentity.TileEntity; 15 | import net.minecraft.util.NonNullList; 16 | 17 | /** 18 | * Author: MrCrayfish 19 | */ 20 | public class DogBowlContainer extends Container 21 | { 22 | private PlayerInventory playerInventory; 23 | private IInventory inventory; 24 | 25 | public DogBowlContainer(int windowId, PlayerInventory playerInventory) 26 | { 27 | this(windowId, playerInventory, new Inventory(1)); 28 | } 29 | 30 | public DogBowlContainer(int windowId, PlayerInventory playerInventory, IInventory inventory) 31 | { 32 | super(ModContainers.DOG_BOWL, windowId); 33 | assertInventorySize(inventory, 1); 34 | inventory.openInventory(playerInventory.player); 35 | this.inventory = inventory; 36 | this.playerInventory = playerInventory; 37 | 38 | this.addSlot(new SlotDogBowl(inventory, 0, 80, 20)); 39 | 40 | for(int i = 0; i < 3; i++) 41 | { 42 | for(int j = 0; j < 9; j++) 43 | { 44 | this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 51 + i * 18)); 45 | } 46 | } 47 | 48 | for(int i = 0; i < 9; i++) 49 | { 50 | this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 109)); 51 | } 52 | 53 | this.addListener(new IContainerListener() 54 | { 55 | @Override 56 | public void sendAllContents(Container containerToSend, NonNullList itemsList) {} 57 | 58 | @Override 59 | public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack) 60 | { 61 | if(slotInd == 0 && inventory instanceof DogBowlTileEntity) 62 | { 63 | TileEntityUtil.sendUpdatePacket((DogBowlTileEntity) inventory); 64 | } 65 | } 66 | 67 | @Override 68 | public void sendWindowProperty(Container containerIn, int varToUpdate, int newValue) {} 69 | }); 70 | } 71 | 72 | @Override 73 | public boolean canInteractWith(PlayerEntity playerIn) 74 | { 75 | return this.inventory.isUsableByPlayer(playerIn); 76 | } 77 | 78 | @Override 79 | public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) 80 | { 81 | ItemStack copyStack = ItemStack.EMPTY; 82 | Slot slot = this.inventorySlots.get(index); 83 | if(slot != null && slot.getHasStack()) 84 | { 85 | ItemStack slotStack = slot.getStack(); 86 | copyStack = slotStack.copy(); 87 | if(index < 1) 88 | { 89 | if(!this.mergeItemStack(slotStack, 1, this.inventorySlots.size(), true)) 90 | { 91 | return ItemStack.EMPTY; 92 | } 93 | } 94 | else if(!this.mergeItemStack(slotStack, 0, 1, false)) 95 | { 96 | return ItemStack.EMPTY; 97 | } 98 | 99 | if(slotStack.isEmpty()) 100 | { 101 | slot.putStack(ItemStack.EMPTY); 102 | } 103 | else 104 | { 105 | slot.onSlotChanged(); 106 | } 107 | } 108 | return copyStack; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/tileentity/BasicLootTileEntity.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.tileentity; 2 | 3 | import net.minecraft.entity.player.PlayerInventory; 4 | import net.minecraft.inventory.ISidedInventory; 5 | import net.minecraft.inventory.ItemStackHelper; 6 | import net.minecraft.inventory.container.Container; 7 | import net.minecraft.item.ItemStack; 8 | import net.minecraft.nbt.CompoundNBT; 9 | import net.minecraft.tileentity.LockableLootTileEntity; 10 | import net.minecraft.tileentity.TileEntityType; 11 | import net.minecraft.util.Direction; 12 | import net.minecraft.util.NonNullList; 13 | import net.minecraft.util.text.ITextComponent; 14 | 15 | import javax.annotation.Nullable; 16 | import java.util.Iterator; 17 | import java.util.stream.IntStream; 18 | 19 | /** 20 | * A simple tile entity class to add an inventory to a block. 21 | * This class is from MrCrayfish's Furniture Mod (https://github.com/MrCrayfish/MrCrayfishFurnitureMod) 22 | * Author: MrCrayfish 23 | */ 24 | public abstract class BasicLootTileEntity extends LockableLootTileEntity implements ISidedInventory 25 | { 26 | private final int[] slots; 27 | protected NonNullList inventory; 28 | 29 | public BasicLootTileEntity(TileEntityType tileEntityType) 30 | { 31 | super(tileEntityType); 32 | this.inventory = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); 33 | this.slots = IntStream.range(0, this.getSizeInventory()).toArray(); 34 | } 35 | 36 | @Override 37 | public abstract int getSizeInventory(); 38 | 39 | @Override 40 | protected abstract ITextComponent getDefaultName(); 41 | 42 | @Override 43 | protected NonNullList getItems() 44 | { 45 | return inventory; 46 | } 47 | 48 | @Override 49 | protected void setItems(NonNullList stacks) 50 | { 51 | this.inventory = stacks; 52 | } 53 | 54 | protected boolean addItem(ItemStack stack) 55 | { 56 | for(int i = 0; i < this.getSizeInventory(); i++) 57 | { 58 | if(this.getStackInSlot(i).isEmpty()) 59 | { 60 | this.setInventorySlotContents(i, stack); 61 | return true; 62 | } 63 | } 64 | return false; 65 | } 66 | 67 | @Override 68 | protected abstract Container createMenu(int windowId, PlayerInventory playerInventory); 69 | 70 | @Override 71 | public boolean isEmpty() 72 | { 73 | Iterator it = this.inventory.iterator(); 74 | ItemStack stack; 75 | do 76 | { 77 | if(!it.hasNext()) 78 | { 79 | return true; 80 | } 81 | stack = (ItemStack) it.next(); 82 | } 83 | while(stack.isEmpty()); 84 | return false; 85 | } 86 | 87 | public boolean isFull() 88 | { 89 | for(ItemStack stack : this.inventory) 90 | { 91 | if(stack.isEmpty()) 92 | { 93 | return false; 94 | } 95 | } 96 | return true; 97 | } 98 | 99 | @Override 100 | public CompoundNBT write(CompoundNBT compound) 101 | { 102 | super.write(compound); 103 | if(!this.checkLootAndWrite(compound)) 104 | { 105 | ItemStackHelper.saveAllItems(compound, this.inventory); 106 | } 107 | return compound; 108 | } 109 | 110 | @Override 111 | public void read(CompoundNBT compound) 112 | { 113 | super.read(compound); 114 | this.inventory = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); 115 | if(!this.checkLootAndRead(compound)) 116 | { 117 | ItemStackHelper.loadAllItems(compound, this.inventory); 118 | } 119 | } 120 | 121 | @Override 122 | public int[] getSlotsForFace(Direction direction) 123 | { 124 | return slots; 125 | } 126 | 127 | @Override 128 | public boolean canInsertItem(int i, ItemStack itemStack, @Nullable Direction direction) 129 | { 130 | return true; 131 | } 132 | 133 | @Override 134 | public boolean canExtractItem(int i, ItemStack itemStack, Direction direction) 135 | { 136 | return true; 137 | } 138 | } -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/common/entity/PlayerDataHandler.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.common.entity; 2 | 3 | import com.mrcrayfish.improvedwolves.Reference; 4 | import net.minecraft.entity.Entity; 5 | import net.minecraft.entity.player.PlayerEntity; 6 | import net.minecraft.nbt.CompoundNBT; 7 | import net.minecraft.nbt.INBT; 8 | import net.minecraft.util.Direction; 9 | import net.minecraft.util.ResourceLocation; 10 | import net.minecraftforge.common.MinecraftForge; 11 | import net.minecraftforge.common.capabilities.Capability; 12 | import net.minecraftforge.common.capabilities.CapabilityInject; 13 | import net.minecraftforge.common.capabilities.CapabilityManager; 14 | import net.minecraftforge.common.capabilities.ICapabilitySerializable; 15 | import net.minecraftforge.common.util.LazyOptional; 16 | import net.minecraftforge.event.AttachCapabilitiesEvent; 17 | import net.minecraftforge.eventbus.api.SubscribeEvent; 18 | 19 | import javax.annotation.Nonnull; 20 | import javax.annotation.Nullable; 21 | import java.util.Optional; 22 | import java.util.UUID; 23 | 24 | /** 25 | * Author: MrCrayfish 26 | */ 27 | public class PlayerDataHandler 28 | { 29 | @CapabilityInject(IPlayerData.class) 30 | public static final Capability CAPABILITY_PLAYER_DATA = null; 31 | 32 | public static void register() 33 | { 34 | CapabilityManager.INSTANCE.register(IPlayerData.class, new PlayerDataHandler.Storage(), PlayerData::new); 35 | MinecraftForge.EVENT_BUS.register(new PlayerDataHandler()); 36 | } 37 | 38 | @Nullable 39 | public static IPlayerData getHandler(PlayerEntity player) 40 | { 41 | return player.getCapability(CAPABILITY_PLAYER_DATA, Direction.DOWN).orElse(null); 42 | } 43 | 44 | @SubscribeEvent 45 | public void attachCapabilities(AttachCapabilitiesEvent event) 46 | { 47 | if(event.getObject() instanceof PlayerEntity) 48 | { 49 | event.addCapability(new ResourceLocation(Reference.MOD_ID, "wolf_data"), new PlayerDataHandler.Provider()); 50 | } 51 | } 52 | 53 | public interface IPlayerData 54 | { 55 | void setCommandingWolf(UUID uuid); 56 | 57 | Optional getCommandingWolf(); 58 | } 59 | 60 | public static class PlayerData implements IPlayerData 61 | { 62 | private UUID commandingWolfUuid = null; 63 | 64 | @Override 65 | public void setCommandingWolf(UUID uuid) 66 | { 67 | this.commandingWolfUuid = uuid; 68 | } 69 | 70 | @Override 71 | public Optional getCommandingWolf() 72 | { 73 | return Optional.ofNullable(this.commandingWolfUuid); 74 | } 75 | } 76 | 77 | public static class Storage implements Capability.IStorage 78 | { 79 | @Nullable 80 | @Override 81 | public INBT writeNBT(Capability capability, IPlayerData instance, Direction side) 82 | { 83 | CompoundNBT compound = new CompoundNBT(); 84 | if(instance.getCommandingWolf().isPresent()) 85 | { 86 | compound.putUniqueId("CommandingWolfUUID", instance.getCommandingWolf().get()); 87 | } 88 | return compound; 89 | } 90 | 91 | @Override 92 | public void readNBT(Capability capability, IPlayerData instance, Direction side, INBT nbt) 93 | { 94 | CompoundNBT compound = (CompoundNBT) nbt; 95 | if(compound.hasUniqueId("CommandingWolfUUID")) 96 | { 97 | instance.setCommandingWolf(compound.getUniqueId("CommandingWolfUUID")); 98 | } 99 | } 100 | } 101 | 102 | public static class Provider implements ICapabilitySerializable 103 | { 104 | final IPlayerData INSTANCE = CAPABILITY_PLAYER_DATA.getDefaultInstance(); 105 | 106 | @Override 107 | public CompoundNBT serializeNBT() 108 | { 109 | return (CompoundNBT) CAPABILITY_PLAYER_DATA.getStorage().writeNBT(CAPABILITY_PLAYER_DATA, INSTANCE, null); 110 | } 111 | 112 | @Override 113 | public void deserializeNBT(CompoundNBT compound) 114 | { 115 | CAPABILITY_PLAYER_DATA.getStorage().readNBT(CAPABILITY_PLAYER_DATA, INSTANCE, null, compound); 116 | } 117 | 118 | @Nonnull 119 | @Override 120 | public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) 121 | { 122 | return CAPABILITY_PLAYER_DATA.orEmpty(cap, LazyOptional.of(() -> INSTANCE)); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/block/DogBowlBlock.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.block; 2 | 3 | import com.mrcrayfish.improvedwolves.tileentity.DogBowlTileEntity; 4 | import com.mrcrayfish.improvedwolves.util.TileEntityUtil; 5 | import net.minecraft.block.Block; 6 | import net.minecraft.block.BlockState; 7 | import net.minecraft.block.HorizontalBlock; 8 | import net.minecraft.block.IWaterLoggable; 9 | import net.minecraft.entity.LivingEntity; 10 | import net.minecraft.entity.player.PlayerEntity; 11 | import net.minecraft.inventory.IInventory; 12 | import net.minecraft.inventory.InventoryHelper; 13 | import net.minecraft.inventory.container.INamedContainerProvider; 14 | import net.minecraft.item.DyeColor; 15 | import net.minecraft.item.ItemStack; 16 | import net.minecraft.state.BooleanProperty; 17 | import net.minecraft.state.StateContainer; 18 | import net.minecraft.state.properties.BlockStateProperties; 19 | import net.minecraft.tileentity.TileEntity; 20 | import net.minecraft.util.ActionResultType; 21 | import net.minecraft.util.Direction; 22 | import net.minecraft.util.Hand; 23 | import net.minecraft.util.math.BlockPos; 24 | import net.minecraft.util.math.BlockRayTraceResult; 25 | import net.minecraft.util.math.shapes.ISelectionContext; 26 | import net.minecraft.util.math.shapes.VoxelShape; 27 | import net.minecraft.world.IBlockReader; 28 | import net.minecraft.world.World; 29 | 30 | import javax.annotation.Nullable; 31 | 32 | /** 33 | * Author: MrCrayfish 34 | */ 35 | public class DogBowlBlock extends HorizontalBlock implements IWaterLoggable 36 | { 37 | public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; 38 | 39 | private final DyeColor color; 40 | private final VoxelShape shape = Block.makeCuboidShape(3, 0, 3, 13, 4, 13); 41 | 42 | public DogBowlBlock(DyeColor color, Properties properties) 43 | { 44 | super(properties); 45 | this.color = color; 46 | this.setDefaultState(this.getStateContainer().getBaseState().with(HORIZONTAL_FACING, Direction.NORTH).with(WATERLOGGED, false)); 47 | } 48 | 49 | public DyeColor getColor() 50 | { 51 | return color; 52 | } 53 | 54 | @Override 55 | public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context) 56 | { 57 | return this.shape; 58 | } 59 | 60 | @Override 61 | public VoxelShape getCollisionShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context) 62 | { 63 | return this.shape; 64 | } 65 | 66 | @Override 67 | public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult p_225533_6_) 68 | { 69 | if(!worldIn.isRemote) 70 | { 71 | TileEntity tileEntity = worldIn.getTileEntity(pos); 72 | if(tileEntity instanceof INamedContainerProvider) 73 | { 74 | player.openContainer((INamedContainerProvider) tileEntity); 75 | } 76 | } 77 | return ActionResultType.SUCCESS; 78 | } 79 | 80 | @Override 81 | public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) 82 | { 83 | if(stack.hasDisplayName()) 84 | { 85 | TileEntity tileentity = worldIn.getTileEntity(pos); 86 | if(tileentity instanceof DogBowlTileEntity) 87 | { 88 | ((DogBowlTileEntity) tileentity).setCustomName(stack.getDisplayName()); 89 | TileEntityUtil.sendUpdatePacket(tileentity); 90 | } 91 | } 92 | } 93 | 94 | @Override 95 | public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) 96 | { 97 | if(state.getBlock() != newState.getBlock()) 98 | { 99 | TileEntity tileentity = worldIn.getTileEntity(pos); 100 | if(tileentity instanceof IInventory) 101 | { 102 | InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory) tileentity); 103 | worldIn.updateComparatorOutputLevel(pos, this); 104 | } 105 | super.onReplaced(state, worldIn, pos, newState, isMoving); 106 | } 107 | } 108 | 109 | @Override 110 | protected void fillStateContainer(StateContainer.Builder builder) 111 | { 112 | super.fillStateContainer(builder); 113 | builder.add(WATERLOGGED); 114 | builder.add(HORIZONTAL_FACING); 115 | } 116 | 117 | @Override 118 | public boolean hasTileEntity(BlockState state) 119 | { 120 | return true; 121 | } 122 | 123 | @Nullable 124 | @Override 125 | public TileEntity createTileEntity(BlockState state, IBlockReader world) 126 | { 127 | return new DogBowlTileEntity(); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/common/entity/WolfHeldItemDataHandler.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.common.entity; 2 | 3 | import com.mrcrayfish.improvedwolves.Reference; 4 | import com.mrcrayfish.improvedwolves.init.ModMemoryModuleTypes; 5 | import net.minecraft.entity.Entity; 6 | import net.minecraft.entity.item.ItemEntity; 7 | import net.minecraft.entity.passive.WolfEntity; 8 | import net.minecraft.item.ItemStack; 9 | import net.minecraft.nbt.CompoundNBT; 10 | import net.minecraft.nbt.INBT; 11 | import net.minecraft.server.MinecraftServer; 12 | import net.minecraft.util.Direction; 13 | import net.minecraft.util.ResourceLocation; 14 | import net.minecraft.util.concurrent.TickDelayedTask; 15 | import net.minecraftforge.common.MinecraftForge; 16 | import net.minecraftforge.common.capabilities.Capability; 17 | import net.minecraftforge.common.capabilities.CapabilityInject; 18 | import net.minecraftforge.common.capabilities.CapabilityManager; 19 | import net.minecraftforge.common.capabilities.ICapabilitySerializable; 20 | import net.minecraftforge.common.util.LazyOptional; 21 | import net.minecraftforge.event.AttachCapabilitiesEvent; 22 | import net.minecraftforge.event.entity.EntityJoinWorldEvent; 23 | import net.minecraftforge.eventbus.api.SubscribeEvent; 24 | 25 | import javax.annotation.Nonnull; 26 | import javax.annotation.Nullable; 27 | import java.util.Optional; 28 | 29 | /** 30 | * Author: MrCrayfish 31 | */ 32 | public class WolfHeldItemDataHandler 33 | { 34 | @CapabilityInject(IWolfHeldItem.class) 35 | public static final Capability CAPABILITY_WOLF_HELD_ITEM = null; 36 | 37 | public static void register() 38 | { 39 | CapabilityManager.INSTANCE.register(IWolfHeldItem.class, new Storage(), WolfHeldItem::new); 40 | MinecraftForge.EVENT_BUS.register(new WolfHeldItemDataHandler()); 41 | } 42 | 43 | @Nullable 44 | public static IWolfHeldItem getHandler(WolfEntity wolf) 45 | { 46 | return wolf.getCapability(CAPABILITY_WOLF_HELD_ITEM, Direction.DOWN).orElse(null); 47 | } 48 | 49 | @SubscribeEvent 50 | public void attachCapabilities(AttachCapabilitiesEvent event) 51 | { 52 | if(event.getObject() instanceof WolfEntity) 53 | { 54 | event.addCapability(new ResourceLocation(Reference.MOD_ID, "wolf_held_item"), new Provider()); 55 | } 56 | } 57 | 58 | @SubscribeEvent 59 | public void onEntityJoin(EntityJoinWorldEvent event) 60 | { 61 | if(event.getEntity() instanceof WolfEntity) 62 | { 63 | WolfEntity wolf = (WolfEntity) event.getEntity(); 64 | WolfHeldItemDataHandler.IWolfHeldItem handler = WolfHeldItemDataHandler.getHandler(wolf); 65 | if(handler != null) 66 | { 67 | ItemStack stack = handler.getItemStack(); 68 | if(!stack.isEmpty()) 69 | { 70 | MinecraftServer server = event.getWorld().getServer(); 71 | if(server != null) 72 | { 73 | wolf.getBrain().setMemory(ModMemoryModuleTypes.CHEST, Optional.empty()); 74 | handler.setItemStack(ItemStack.EMPTY); 75 | server.enqueue(new TickDelayedTask(1, () -> event.getWorld().addEntity(new ItemEntity(event.getWorld(), wolf.getPosX(), wolf.getPosY(), wolf.getPosZ(), stack.copy())))); 76 | } 77 | } 78 | } 79 | } 80 | } 81 | 82 | public interface IWolfHeldItem 83 | { 84 | void setItemStack(ItemStack stack); 85 | 86 | ItemStack getItemStack(); 87 | } 88 | 89 | public static class WolfHeldItem implements IWolfHeldItem 90 | { 91 | private ItemStack stack = ItemStack.EMPTY; 92 | 93 | @Override 94 | public void setItemStack(ItemStack stack) 95 | { 96 | this.stack = stack; 97 | } 98 | 99 | @Override 100 | public ItemStack getItemStack() 101 | { 102 | return stack; 103 | } 104 | } 105 | 106 | public static class Storage implements Capability.IStorage 107 | { 108 | @Nullable 109 | @Override 110 | public INBT writeNBT(Capability capability, IWolfHeldItem instance, Direction side) 111 | { 112 | return instance.getItemStack().write(new CompoundNBT()); 113 | } 114 | 115 | @Override 116 | public void readNBT(Capability capability, IWolfHeldItem instance, Direction side, INBT nbt) 117 | { 118 | instance.setItemStack(ItemStack.read((CompoundNBT) nbt)); 119 | } 120 | } 121 | 122 | public static class Provider implements ICapabilitySerializable 123 | { 124 | final IWolfHeldItem INSTANCE = CAPABILITY_WOLF_HELD_ITEM.getDefaultInstance(); 125 | 126 | @Override 127 | public CompoundNBT serializeNBT() 128 | { 129 | return (CompoundNBT) CAPABILITY_WOLF_HELD_ITEM.getStorage().writeNBT(CAPABILITY_WOLF_HELD_ITEM, INSTANCE, null); 130 | } 131 | 132 | @Override 133 | public void deserializeNBT(CompoundNBT compound) 134 | { 135 | CAPABILITY_WOLF_HELD_ITEM.getStorage().readNBT(CAPABILITY_WOLF_HELD_ITEM, INSTANCE, null, compound); 136 | } 137 | 138 | @Nonnull 139 | @Override 140 | public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) 141 | { 142 | return CAPABILITY_WOLF_HELD_ITEM.orEmpty(cap, LazyOptional.of(() -> INSTANCE)); 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/init/ModBlocks.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.init; 2 | 3 | import com.mrcrayfish.improvedwolves.ImprovedWolves; 4 | import com.mrcrayfish.improvedwolves.Reference; 5 | import com.mrcrayfish.improvedwolves.block.DogBowlBlock; 6 | import net.minecraft.block.BedBlock; 7 | import net.minecraft.block.Block; 8 | import net.minecraft.block.SoundType; 9 | import net.minecraft.block.material.Material; 10 | import net.minecraft.item.BlockItem; 11 | import net.minecraft.item.DyeColor; 12 | import net.minecraft.item.Item; 13 | import net.minecraftforge.event.RegistryEvent; 14 | import net.minecraftforge.eventbus.api.SubscribeEvent; 15 | import net.minecraftforge.fml.common.Mod; 16 | 17 | import javax.annotation.Nullable; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | import java.util.function.Function; 21 | 22 | /** 23 | * Author: MrCrayfish 24 | */ 25 | @Mod.EventBusSubscriber(modid = Reference.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) 26 | public class ModBlocks 27 | { 28 | private static final List BLOCKS = new ArrayList<>(); 29 | private static final List ITEMS = new ArrayList<>(); 30 | 31 | public static final Block WHITE_DOG_BOWL = register(new DogBowlBlock(DyeColor.WHITE, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "white_dog_bowl")); 32 | public static final Block ORANGE_DOG_BOWL = register(new DogBowlBlock(DyeColor.ORANGE, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "orange_dog_bowl")); 33 | public static final Block MAGENTA_DOG_BOWL = register(new DogBowlBlock(DyeColor.MAGENTA, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "magenta_dog_bowl")); 34 | public static final Block LIGHT_BLUE_DOG_BOWL = register(new DogBowlBlock(DyeColor.LIGHT_BLUE, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "light_blue_dog_bowl")); 35 | public static final Block YELLOW_DOG_BOWL = register(new DogBowlBlock(DyeColor.YELLOW, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "yellow_dog_bowl")); 36 | public static final Block LIME_DOG_BOWL = register(new DogBowlBlock(DyeColor.LIME, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "lime_dog_bowl")); 37 | public static final Block PINK_DOG_BOWL = register(new DogBowlBlock(DyeColor.PINK, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "pink_dog_bowl")); 38 | public static final Block GRAY_DOG_BOWL = register(new DogBowlBlock(DyeColor.GRAY, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "gray_dog_bowl")); 39 | public static final Block LIGHT_GRAY_DOG_BOWL = register(new DogBowlBlock(DyeColor.LIGHT_GRAY, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "light_gray_dog_bowl")); 40 | public static final Block CYAN_DOG_BOWL = register(new DogBowlBlock(DyeColor.CYAN, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "cyan_dog_bowl")); 41 | public static final Block PURPLE_DOG_BOWL = register(new DogBowlBlock(DyeColor.PURPLE, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "purple_dog_bowl")); 42 | public static final Block BLUE_DOG_BOWL = register(new DogBowlBlock(DyeColor.BLUE, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "blue_dog_bowl")); 43 | public static final Block BROWN_DOG_BOWL = register(new DogBowlBlock(DyeColor.BROWN, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "brown_dog_bowl")); 44 | public static final Block GREEN_DOG_BOWL = register(new DogBowlBlock(DyeColor.GREEN, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "green_dog_bowl")); 45 | public static final Block RED_DOG_BOWL = register(new DogBowlBlock(DyeColor.RED, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "red_dog_bowl")); 46 | public static final Block BLACK_DOG_BOWL = register(new DogBowlBlock(DyeColor.BLACK, Block.Properties.create(Material.WOOD).hardnessAndResistance(0.2F).notSolid()).setRegistryName(Reference.MOD_ID, "black_dog_bowl")); 47 | 48 | private static Block register(Block block) 49 | { 50 | return register(block, block1 -> new BlockItem(block1, new Item.Properties().group(ImprovedWolves.GROUP))); 51 | } 52 | 53 | private static Block register(Block block, @Nullable Function supplier) 54 | { 55 | if(block.getRegistryName() == null) 56 | { 57 | throw new IllegalArgumentException("A block being registered does not have a registry name and could be registered."); 58 | } 59 | 60 | BLOCKS.add(block); 61 | if(supplier != null) 62 | { 63 | BlockItem item = supplier.apply(block); 64 | item.setRegistryName(block.getRegistryName()); 65 | ITEMS.add(item); 66 | } 67 | return block; 68 | } 69 | 70 | @SubscribeEvent 71 | public static void registerBlocks(final RegistryEvent.Register event) 72 | { 73 | BLOCKS.forEach(block -> event.getRegistry().register(block)); 74 | } 75 | 76 | @SubscribeEvent 77 | public static void registerItems(final RegistryEvent.Register event) 78 | { 79 | ITEMS.forEach(block -> event.getRegistry().register(block)); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/entity/ai/goal/MoveToDogBowlGoal.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.entity.ai.goal; 2 | 3 | import com.mrcrayfish.improvedwolves.block.DogBowlBlock; 4 | import com.mrcrayfish.improvedwolves.init.ModBlocks; 5 | import com.mrcrayfish.improvedwolves.tileentity.DogBowlTileEntity; 6 | import net.minecraft.entity.ai.goal.Goal; 7 | import net.minecraft.entity.passive.TameableEntity; 8 | import net.minecraft.item.Food; 9 | import net.minecraft.item.ItemStack; 10 | import net.minecraft.item.Items; 11 | import net.minecraft.particles.ItemParticleData; 12 | import net.minecraft.particles.ParticleTypes; 13 | import net.minecraft.tileentity.TileEntity; 14 | import net.minecraft.util.SoundCategory; 15 | import net.minecraft.util.math.BlockPos; 16 | import net.minecraft.world.World; 17 | import net.minecraft.world.server.ServerWorld; 18 | 19 | import java.util.ArrayList; 20 | import java.util.Comparator; 21 | import java.util.EnumSet; 22 | import java.util.List; 23 | 24 | /** 25 | * Author: MrCrayfish 26 | */ 27 | public class MoveToDogBowlGoal extends Goal 28 | { 29 | private int eatingTicks; 30 | private BlockPos bowlPos; 31 | private DogBowlTileEntity bowlTileEntity; 32 | private TameableEntity entity; 33 | 34 | public MoveToDogBowlGoal(TameableEntity entity) 35 | { 36 | this.entity = entity; 37 | this.setMutexFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.JUMP, Flag.LOOK)); 38 | } 39 | 40 | @Override 41 | public boolean shouldExecute() 42 | { 43 | if(!this.entity.isTamed() || this.entity.isSitting() || this.entity.getHealth() >= this.entity.getMaxHealth()) 44 | { 45 | return false; 46 | } 47 | this.findNearestDogBowl(); 48 | return this.bowlPos != null && this.bowlTileEntity != null && !this.bowlTileEntity.isRemoved() && this.bowlTileEntity.hasFood(); 49 | } 50 | 51 | @Override 52 | public void startExecuting() 53 | { 54 | this.entity.getNavigator().tryMoveToXYZ(this.bowlPos.getX() + 0.5, this.bowlPos.getY(), this.bowlPos.getZ() + 0.5, 1); 55 | } 56 | 57 | @Override 58 | public void tick() 59 | { 60 | if(!this.bowlPos.withinDistance(this.entity.getPositionVec(), 1.2)) 61 | { 62 | this.entity.getNavigator().tryMoveToXYZ(this.bowlPos.getX() + 0.5, this.bowlPos.getY(), this.bowlPos.getZ() + 0.5, 1); 63 | } 64 | else if(!this.bowlTileEntity.isRemoved() && this.bowlTileEntity.hasFood()) 65 | { 66 | this.entity.getNavigator().clearPath(); 67 | this.entity.getLookController().setLookPosition(this.bowlPos.getX() + 0.5, this.bowlPos.getY(), this.bowlPos.getZ() + 0.5); 68 | this.eatingTicks++; 69 | if(this.eatingTicks == 20) 70 | { 71 | //TODO make this depend on the food 72 | Food food = this.bowlTileEntity.getFood(); 73 | if(food != null) 74 | { 75 | this.entity.setHealth(this.entity.getHealth() + food.getHealing()); 76 | this.bowlTileEntity.consumeFood(); 77 | } 78 | this.eatingTicks = 0; 79 | } 80 | else 81 | { 82 | World world = this.entity.getEntityWorld(); 83 | if(world instanceof ServerWorld) 84 | { 85 | ServerWorld serverWorld = (ServerWorld) world; 86 | ItemStack food = new ItemStack(Items.COOKED_BEEF); 87 | serverWorld.spawnParticle(new ItemParticleData(ParticleTypes.ITEM, food), this.bowlPos.getX() + 0.5, this.bowlPos.getY() + 0.0625 * 4, this.bowlPos.getZ() + 0.5, 2, 0.05, 0, 0.05, 0.05); 88 | if(this.eatingTicks % 4 == 0) 89 | { 90 | serverWorld.playSound(null, this.bowlPos, food.func_226630_G_(), SoundCategory.NEUTRAL, 0.5F + 0.5F * serverWorld.rand.nextInt(2), (serverWorld.rand.nextFloat() - serverWorld.rand.nextFloat()) * 0.2F + 1.0F); 91 | } 92 | } 93 | } 94 | } 95 | } 96 | 97 | @Override 98 | public boolean shouldContinueExecuting() 99 | { 100 | return this.entity.getHealth() < this.entity.getMaxHealth() && !this.bowlTileEntity.isRemoved() && this.bowlTileEntity.hasFood(); 101 | } 102 | 103 | @Override 104 | public void resetTask() 105 | { 106 | this.eatingTicks = 0; 107 | this.bowlPos = null; 108 | this.bowlTileEntity = null; 109 | } 110 | 111 | private void findNearestDogBowl() 112 | { 113 | BlockPos center = new BlockPos(this.entity); 114 | List dogBowls = new ArrayList<>(); 115 | BlockPos.getAllInBox(center.add(-10, -10, -10), center.add(10, 10, 10)).forEach(pos -> 116 | { 117 | if(this.entity.getEntityWorld().getBlockState(pos).getBlock() instanceof DogBowlBlock) 118 | { 119 | dogBowls.add(pos.toImmutable()); 120 | } 121 | }); 122 | BlockPos bowlPos = dogBowls.stream().min(Comparator.comparing(pos -> pos.manhattanDistance(center))).orElse(null); 123 | if(bowlPos != null) 124 | { 125 | TileEntity tileEntity = this.entity.getEntityWorld().getTileEntity(bowlPos); 126 | if(tileEntity instanceof DogBowlTileEntity) 127 | { 128 | DogBowlTileEntity dogBowlTileEntity = (DogBowlTileEntity) tileEntity; 129 | if(dogBowlTileEntity.hasCustomName()) 130 | { 131 | if(!dogBowlTileEntity.getName().getUnformattedComponentText().equals(this.entity.getName().getUnformattedComponentText())) 132 | { 133 | return; 134 | } 135 | } 136 | this.bowlPos = bowlPos; 137 | this.bowlTileEntity = (DogBowlTileEntity) tileEntity; 138 | } 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/client/ClientHandler.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.client; 2 | 3 | import com.mojang.blaze3d.matrix.MatrixStack; 4 | import com.mrcrayfish.improvedwolves.Reference; 5 | import com.mrcrayfish.improvedwolves.block.DogBowlBlock; 6 | import com.mrcrayfish.improvedwolves.client.render.tileentity.DogBowlRenderer; 7 | import com.mrcrayfish.improvedwolves.client.screen.DogBowlScreen; 8 | import com.mrcrayfish.improvedwolves.common.entity.WolfHeldItemDataHandler; 9 | import com.mrcrayfish.improvedwolves.init.ModBlocks; 10 | import com.mrcrayfish.improvedwolves.init.ModContainers; 11 | import com.mrcrayfish.improvedwolves.init.ModTileEntities; 12 | import com.mrcrayfish.improvedwolves.network.PacketHandler; 13 | import com.mrcrayfish.improvedwolves.network.message.MessageWolfDepositItem; 14 | import net.minecraft.block.Block; 15 | import net.minecraft.client.Minecraft; 16 | import net.minecraft.client.gui.ScreenManager; 17 | import net.minecraft.client.renderer.Vector3f; 18 | import net.minecraft.client.renderer.model.ItemCameraTransforms; 19 | import net.minecraft.client.renderer.texture.OverlayTexture; 20 | import net.minecraft.client.settings.KeyBinding; 21 | import net.minecraft.entity.Entity; 22 | import net.minecraft.entity.passive.WolfEntity; 23 | import net.minecraft.item.BlockItem; 24 | import net.minecraft.item.ItemStack; 25 | import net.minecraft.util.math.BlockPos; 26 | import net.minecraft.util.math.BlockRayTraceResult; 27 | import net.minecraft.util.math.MathHelper; 28 | import net.minecraft.util.math.RayTraceResult; 29 | import net.minecraft.world.World; 30 | import net.minecraftforge.client.event.InputEvent; 31 | import net.minecraftforge.client.event.RenderLivingEvent; 32 | import net.minecraftforge.eventbus.api.SubscribeEvent; 33 | import net.minecraftforge.fml.client.registry.ClientRegistry; 34 | import net.minecraftforge.fml.common.Mod; 35 | import org.lwjgl.glfw.GLFW; 36 | 37 | /** 38 | * Author: MrCrayfish 39 | */ 40 | @Mod.EventBusSubscriber(modid = Reference.MOD_ID) 41 | public class ClientHandler 42 | { 43 | public static final KeyBinding KEY_COMMAND_DEPOSIT = new KeyBinding("key.improvedwolves.deposit", GLFW.GLFW_KEY_U, "key.categories.improvedwolves"); 44 | 45 | public static void setup() 46 | { 47 | Minecraft.getInstance().getItemColors().register((stack, index) -> { 48 | Block block = Block.getBlockFromItem(stack.getItem()); 49 | return block instanceof DogBowlBlock ? ((DogBowlBlock) block).getColor().getColorValue() : 0xFFFFFF; 50 | }, ModBlocks.WHITE_DOG_BOWL, ModBlocks.ORANGE_DOG_BOWL, ModBlocks.MAGENTA_DOG_BOWL, ModBlocks.LIGHT_BLUE_DOG_BOWL, ModBlocks.YELLOW_DOG_BOWL, ModBlocks.LIME_DOG_BOWL, ModBlocks.PINK_DOG_BOWL, ModBlocks.GRAY_DOG_BOWL, ModBlocks.LIGHT_GRAY_DOG_BOWL, ModBlocks.CYAN_DOG_BOWL, ModBlocks.PURPLE_DOG_BOWL, ModBlocks.BLUE_DOG_BOWL, ModBlocks.BROWN_DOG_BOWL, ModBlocks.GREEN_DOG_BOWL, ModBlocks.RED_DOG_BOWL, ModBlocks.BLACK_DOG_BOWL); 51 | 52 | Minecraft.getInstance().getBlockColors().register((state, reader, pos, index) -> { 53 | Block block = state.getBlock(); 54 | return block instanceof DogBowlBlock ? ((DogBowlBlock) block).getColor().getColorValue() : 0xFFFFFF; 55 | }, ModBlocks.WHITE_DOG_BOWL, ModBlocks.ORANGE_DOG_BOWL, ModBlocks.MAGENTA_DOG_BOWL, ModBlocks.LIGHT_BLUE_DOG_BOWL, ModBlocks.YELLOW_DOG_BOWL, ModBlocks.LIME_DOG_BOWL, ModBlocks.PINK_DOG_BOWL, ModBlocks.GRAY_DOG_BOWL, ModBlocks.LIGHT_GRAY_DOG_BOWL, ModBlocks.CYAN_DOG_BOWL, ModBlocks.PURPLE_DOG_BOWL, ModBlocks.BLUE_DOG_BOWL, ModBlocks.BROWN_DOG_BOWL, ModBlocks.GREEN_DOG_BOWL, ModBlocks.RED_DOG_BOWL, ModBlocks.BLACK_DOG_BOWL); 56 | 57 | ScreenManager.registerFactory(ModContainers.DOG_BOWL, DogBowlScreen::new); 58 | ClientRegistry.bindTileEntityRenderer(ModTileEntities.DOG_BOWL, DogBowlRenderer::new); 59 | ClientRegistry.registerKeyBinding(KEY_COMMAND_DEPOSIT); 60 | } 61 | 62 | @SubscribeEvent 63 | public static void onKeyPress(InputEvent.KeyInputEvent event) 64 | { 65 | if(event.getAction() == GLFW.GLFW_PRESS && event.getKey() == KEY_COMMAND_DEPOSIT.getKey().getKeyCode()) 66 | { 67 | if(Minecraft.getInstance().player != null) 68 | { 69 | RayTraceResult result = Minecraft.getInstance().player.pick(20.0D, Minecraft.getInstance().getRenderPartialTicks(), false); 70 | if(result.getType() == RayTraceResult.Type.BLOCK || result.getType() == RayTraceResult.Type.MISS) 71 | { 72 | BlockRayTraceResult blockRayTraceResult = (BlockRayTraceResult) result; 73 | BlockPos pos = blockRayTraceResult.getPos(); 74 | if(result.getType() == RayTraceResult.Type.MISS || pos.withinDistance(Minecraft.getInstance().player.getEyePosition(0F), 20.0D)) 75 | { 76 | PacketHandler.instance.sendToServer(new MessageWolfDepositItem(pos, result.getType() == RayTraceResult.Type.MISS)); 77 | } 78 | } 79 | } 80 | } 81 | } 82 | 83 | @SubscribeEvent 84 | public static void onRenderWolf(RenderLivingEvent.Post event) 85 | { 86 | if(event.getEntity() instanceof WolfEntity) 87 | { 88 | WolfEntity wolf = (WolfEntity) event.getEntity(); 89 | WolfHeldItemDataHandler.IWolfHeldItem handler = WolfHeldItemDataHandler.getHandler(wolf); 90 | if(handler != null) 91 | { 92 | ItemStack heldItem = handler.getItemStack(); 93 | if(!heldItem.isEmpty()) 94 | { 95 | MatrixStack matrix = event.getMatrixStack(); 96 | matrix.push(); 97 | matrix.rotate(Vector3f.YP.rotationDegrees(MathHelper.lerp(event.getPartialRenderTick(), -wolf.prevRenderYawOffset, -wolf.renderYawOffset))); 98 | matrix.translate(-1 * 0.0625, 0, 7 * 0.0625); 99 | matrix.rotate(Vector3f.YN.rotationDegrees(MathHelper.lerp(event.getPartialRenderTick(), -wolf.prevRenderYawOffset, -wolf.renderYawOffset))); 100 | matrix.rotate(Vector3f.YP.rotationDegrees(MathHelper.lerp(event.getPartialRenderTick(), -wolf.prevRotationYawHead, -wolf.rotationYawHead))); 101 | matrix.rotate(Vector3f.XP.rotationDegrees(MathHelper.lerp(event.getPartialRenderTick(), wolf.prevRotationPitch, wolf.rotationPitch))); 102 | matrix.translate(1 * 0.0625, 8.5 * 0.0625, 5 * 0.0625); 103 | if(heldItem.getItem() instanceof BlockItem) 104 | { 105 | matrix.translate(0, -1.0 * 0.0625, 0); 106 | matrix.rotate(Vector3f.XP.rotationDegrees(75F)); 107 | matrix.scale(0.2F, 0.2F, 0.2F); 108 | } 109 | else 110 | { 111 | matrix.scale(0.4F, 0.4F, 0.4F); 112 | } 113 | matrix.rotate(Vector3f.YP.rotationDegrees(90F)); 114 | matrix.rotate(Vector3f.XP.rotationDegrees(90F)); 115 | Minecraft.getInstance().getItemRenderer().renderItem(heldItem, ItemCameraTransforms.TransformType.NONE, event.getLight(), OverlayTexture.DEFAULT_LIGHT, matrix, event.getBuffers()); 116 | matrix.pop(); 117 | } 118 | } 119 | } 120 | } 121 | 122 | public static void setWolfHeldItem(int entityId, ItemStack stack) 123 | { 124 | World world = Minecraft.getInstance().world; 125 | if(world != null) 126 | { 127 | Entity entity = world.getEntityByID(entityId); 128 | if(entity instanceof WolfEntity) 129 | { 130 | WolfEntity wolf = (WolfEntity) entity; 131 | WolfHeldItemDataHandler.IWolfHeldItem heldItem = WolfHeldItemDataHandler.getHandler(wolf); 132 | if(heldItem != null) 133 | { 134 | heldItem.setItemStack(stack); 135 | } 136 | } 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/network/message/MessageWolfDepositItem.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.network.message; 2 | 3 | import com.mrcrayfish.improvedwolves.common.entity.PlayerDataHandler; 4 | import com.mrcrayfish.improvedwolves.entity.ai.goal.PutInChestGoal; 5 | import com.mrcrayfish.improvedwolves.init.ModMemoryModuleTypes; 6 | import com.mrcrayfish.improvedwolves.init.ModSounds; 7 | import net.minecraft.entity.EntityType; 8 | import net.minecraft.entity.ai.brain.Brain; 9 | import net.minecraft.entity.ai.goal.PrioritizedGoal; 10 | import net.minecraft.entity.passive.WolfEntity; 11 | import net.minecraft.entity.player.ServerPlayerEntity; 12 | import net.minecraft.inventory.IInventory; 13 | import net.minecraft.item.ItemStack; 14 | import net.minecraft.network.PacketBuffer; 15 | import net.minecraft.tileentity.TileEntity; 16 | import net.minecraft.util.SoundCategory; 17 | import net.minecraft.util.math.BlockPos; 18 | import net.minecraft.util.math.GlobalPos; 19 | import net.minecraft.util.text.ChatType; 20 | import net.minecraft.util.text.TranslationTextComponent; 21 | import net.minecraft.world.server.ServerWorld; 22 | import net.minecraftforge.fml.network.NetworkEvent; 23 | 24 | import java.util.Comparator; 25 | import java.util.List; 26 | import java.util.Optional; 27 | import java.util.UUID; 28 | import java.util.function.Supplier; 29 | 30 | /** 31 | * Author: MrCrayfish 32 | */ 33 | public class MessageWolfDepositItem implements IMessage 34 | { 35 | private BlockPos pos; 36 | private boolean miss; 37 | 38 | public MessageWolfDepositItem() {} 39 | 40 | public MessageWolfDepositItem(BlockPos pos, boolean miss) 41 | { 42 | this.pos = pos; 43 | this.miss = miss; 44 | } 45 | 46 | @Override 47 | public void encode(MessageWolfDepositItem message, PacketBuffer buffer) 48 | { 49 | buffer.writeBlockPos(message.pos); 50 | buffer.writeBoolean(message.miss); 51 | } 52 | 53 | @Override 54 | public MessageWolfDepositItem decode(PacketBuffer buffer) 55 | { 56 | return new MessageWolfDepositItem(buffer.readBlockPos(), buffer.readBoolean()); 57 | } 58 | 59 | @Override 60 | public void handle(MessageWolfDepositItem message, Supplier supplier) 61 | { 62 | supplier.get().enqueueWork(() -> 63 | { 64 | ServerPlayerEntity player = supplier.get().getSender(); 65 | if(player != null) 66 | { 67 | if(!message.miss && !message.pos.withinDistance(player.getEyePosition(0F), 20.0D)) 68 | { 69 | return; 70 | } 71 | 72 | ServerWorld world = player.getServerWorld(); 73 | WolfEntity commandingWolf = null; 74 | PlayerDataHandler.IPlayerData playerDataHandler = PlayerDataHandler.getHandler(player); 75 | if(playerDataHandler == null) 76 | { 77 | return; 78 | } 79 | Optional optional = playerDataHandler.getCommandingWolf(); 80 | if(optional.isPresent()) 81 | { 82 | UUID uuid = optional.get(); 83 | List wolves = world.getEntitiesWithinAABB(EntityType.WOLF, player.getBoundingBox().grow(20), wolf -> wolf.isTamed() && wolf.getUniqueID().equals(uuid) && wolf.getOwnerId() != null && wolf.getOwnerId().equals(player.getUniqueID())); 84 | if(wolves.size() > 0) 85 | { 86 | commandingWolf = wolves.get(0); 87 | } 88 | else 89 | { 90 | playerDataHandler.setCommandingWolf(null); 91 | } 92 | } 93 | if(commandingWolf == null) 94 | { 95 | List wolves = world.getEntitiesWithinAABB(EntityType.WOLF, player.getBoundingBox().grow(20), wolf -> wolf.isTamed() && wolf.getOwnerId() != null && wolf.getOwnerId().equals(player.getUniqueID())); 96 | commandingWolf = wolves.stream().min(Comparator.comparing(player::getDistance)).orElse(null); 97 | } 98 | if(commandingWolf != null) 99 | { 100 | if(commandingWolf.isSitting()) 101 | { 102 | return; 103 | } 104 | if(commandingWolf.getNavigator().getPathToEntity(player, 1) == null) 105 | { 106 | return; 107 | } 108 | playerDataHandler.setCommandingWolf(commandingWolf.getUniqueID()); 109 | Brain brain = commandingWolf.getBrain(); 110 | if(brain.getMemory(ModMemoryModuleTypes.CHEST).isPresent()) 111 | { 112 | TileEntity tileEntity = world.getTileEntity(message.pos); 113 | if(!message.miss && tileEntity instanceof IInventory && !brain.getMemory(ModMemoryModuleTypes.CHEST).get().getPos().equals(message.pos)) 114 | { 115 | ItemStack heldItem = player.getHeldItemMainhand(); 116 | if(heldItem.isEmpty()) 117 | { 118 | return; 119 | } 120 | if(PutInChestGoal.canInsertItemIntoStorage((IInventory) tileEntity, heldItem)) 121 | { 122 | brain.setMemory(ModMemoryModuleTypes.CHEST, GlobalPos.of(player.dimension, message.pos)); 123 | world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), ModSounds.ENTITY_PLAYER_WHISTLE, SoundCategory.PLAYERS, 1.0F, 1.0F); 124 | } 125 | else 126 | { 127 | player.sendMessage(new TranslationTextComponent("info.improvedwolves.storage_full", tileEntity.getBlockState().getBlock().getNameTextComponent()), ChatType.GAME_INFO); 128 | } 129 | } 130 | else 131 | { 132 | brain.setMemory(ModMemoryModuleTypes.CHEST, Optional.empty()); 133 | world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), ModSounds.ENTITY_PLAYER_WHISTLE, SoundCategory.PLAYERS, 1.0F, 0.5F); 134 | } 135 | } 136 | else 137 | { 138 | TileEntity tileEntity = world.getTileEntity(message.pos); 139 | if(tileEntity instanceof IInventory) 140 | { 141 | ItemStack heldItem = player.getHeldItemMainhand(); 142 | if(heldItem.isEmpty()) 143 | { 144 | return; 145 | } 146 | if(PutInChestGoal.canInsertItemIntoStorage((IInventory) tileEntity, heldItem)) 147 | { 148 | brain.setMemory(ModMemoryModuleTypes.CHEST, GlobalPos.of(player.dimension, message.pos)); 149 | commandingWolf.goalSelector.getRunningGoals().forEach(PrioritizedGoal::resetTask); 150 | world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), ModSounds.ENTITY_PLAYER_WHISTLE, SoundCategory.PLAYERS, 1.0F, 1.0F); 151 | } 152 | else 153 | { 154 | player.sendMessage(new TranslationTextComponent("info.improvedwolves.storage_full", tileEntity.getBlockState().getBlock().getNameTextComponent()), ChatType.GAME_INFO); 155 | } 156 | } 157 | } 158 | } 159 | } 160 | }); 161 | supplier.get().setPacketHandled(true); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | Build: 1.15.2-31.1.0 - Mon Feb 03 21:24:29 GMT 2020 2 | lex: 3 | Fix a small patch misalignment. 4 | 5 | ========= 6 | Build: 1.15.2-31.0.19 - Mon Feb 03 20:52:28 GMT 2020 7 | richard: 8 | Add FluidStack support to the Forge packet buffer. (#6353) (#6485) 9 | 10 | richard: 11 | Make Minecarts work with modded powered/activator rails. (#6486) 12 | 13 | Re-adds functionality for rails to have different maximum speeds. 14 | 15 | ========= 16 | Build: 1.15.2-31.0.17 - Mon Feb 03 20:21:20 GMT 2020 17 | ichttt: 18 | Revert game data to frozen on disconnect from a remote server or when terminating a local server. Closes #6487 (#6497) 19 | 20 | ========= 21 | Build: 1.15.2-31.0.16 - Sun Feb 02 22:11:19 GMT 2020 22 | David Quintana: 23 | Remove unintended changes. 24 | 25 | ========= 26 | Build: 1.15.2-31.0.15 - Sun Feb 02 22:03:15 GMT 2020 27 | David Quintana: 28 | Implement fluid overlay texture rendering for custom fluids. 29 | 30 | ========= 31 | Build: 1.15.2-31.0.14 - Thu Jan 30 06:12:15 GMT 2020 32 | DaemonUmbra: 33 | Fixed Attacks/Punches not Registering (#6481) 34 | 35 | Replaced incorrect magic number with constant 36 | 37 | ========= 38 | Build: 1.15.2-31.0.13 - Wed Jan 29 23:46:30 GMT 2020 39 | williewillus: 40 | Clean up a bunch of render events (#6444) 41 | 42 | * Delete RenderHandEvent as RenderSpecificHandEvent can do everything it does and more. Rename RenderSpecificHandEvent to RenderHandEvent as it's now the only hand rendering event. 43 | * Pass MatrixStack and IRenderTypeBuffer into the event whenever they are available. If they're available, that means we're in a batching environment and the modder should not be using the tessellator or other buffers on their own, or they risk "Already building" crashes. 44 | 45 | ========= 46 | Build: 1.15.2-31.0.12 - Wed Jan 29 21:55:18 GMT 2020 47 | Barteks2x: 48 | Fix NullPointerException on java 8u242 in dev environment. (#6473) 49 | 50 | Java 8u242 no longer re-initializes internal sys_paths and usr_paths fields in loadLibrary when they are null, so the value can't be set to null. 51 | 52 | ========= 53 | Build: 1.15.2-31.0.11 - Wed Jan 29 21:18:05 GMT 2020 54 | 12281102+Aeltumn: 55 | Fix RightClickBlock code differences between client and server implementation (#6451) 56 | 57 | williewillus: 58 | Fix incorrectly ported patch for restoreBlurMipmap (#6450) 59 | 60 | ========= 61 | Build: 1.15.2-31.0.9 - Wed Jan 29 21:11:24 GMT 2020 62 | 40495288+Yamahari: 63 | Defer material getting for ChestTileEntityRenderer into seperate function (#6465) 64 | 65 | ========= 66 | Build: 1.15.2-31.0.8 - Wed Jan 29 21:04:44 GMT 2020 67 | 37298044+Cadiboo: 68 | Small Forge config fixes (#6466) 69 | 70 | ========= 71 | Build: 1.15.2-31.0.7 - Wed Jan 29 20:50:44 GMT 2020 72 | lex: 73 | Fix PlayerChangedDimensionEvent using incorrect from dimension argument in ServerPlayerEntity.teleport. Closes #6457 74 | 75 | lex: 76 | Fix incorrect keybinding modifiers patch. Closes #6478 77 | 78 | lex: 79 | Fix ChunkDataEvent.Load not firing, it now fires in the aync thread. Be careful. Closes #6471 80 | 81 | ========= 82 | Build: 1.15.2-31.0.4 - Wed Jan 29 19:31:50 GMT 2020 83 | lex: 84 | Fix WakeupEvent patch misalign. Closes #6474 85 | 86 | lex: 87 | Fix default mod resources loosing it's sort order. 88 | 89 | ========= 90 | Build: 1.15.2-31.0.2 - Wed Jan 29 17:26:58 GMT 2020 91 | goto.minecraft: 92 | [1.15] Reimplemented the ITeleporter interface (#6404) 93 | 94 | ========= 95 | Build: 1.15.2-31.0.1 - Thu Jan 23 21:59:18 GMT 2020 96 | David Quintana: 97 | Hook "gui_light" value from the model into the IBakedModel implementations. 98 | Apply some of the suggestions from the 1.14 models PR. 99 | 100 | ========= 101 | Build: 1.15.2-31.0.0 - Wed Jan 22 21:47:51 GMT 2020 102 | lex: 103 | 1.15.2 Initial Update 104 | 105 | ========= 106 | Build: 1.15.1-30.0.51 - Wed Jan 22 21:10:07 GMT 2020 107 | ichttt: 108 | Cleanup fml packages removing old deprecated classes related to GUIs/Configs and fix HoverChecker (#6437) 109 | 110 | Fixed ModListWidget name to avoid confusion and collision. 111 | Delete CheckBox, as vanilla has it's own CheckBox now which looks much better 112 | Rename ModConfigEvent.ConfigReloading to ModConfigEvent.Reloading 113 | 114 | ========= 115 | Build: 1.15.1-30.0.50 - Wed Jan 22 20:38:22 GMT 2020 116 | 12281102+Aeltumn: 117 | Fixed parameter name issue in ISTER rename. #6461 (#6468) 118 | 119 | ========= 120 | Build: 1.15.1-30.0.49 - Wed Jan 22 19:56:16 GMT 2020 121 | lex: 122 | Fix default widget foreground color. 123 | 124 | ========= 125 | Build: 1.15.1-30.0.48 - Wed Jan 22 19:30:35 GMT 2020 126 | diesieben07: 127 | Use extended version of getLightValue in all places (#6433) 128 | 129 | Bward7864: 130 | Fixed RenderTypeLookup loosing mappings for registry replacements. (#6452) 131 | 132 | wynprice999: 133 | Fixed rounding issue with entity navigation fix (#6455) (#6456) 134 | 135 | 37298044+Cadiboo: 136 | Fix Widget Foreground Color not allowing pure black (#6460) 137 | 138 | 12281102+Aeltumn: 139 | Updated method names referencing ItemStackTileEntityRenderer (#6461) 140 | 141 | ========= 142 | Build: 1.15.1-30.0.43 - Wed Jan 22 19:22:15 GMT 2020 143 | scottehboeh: 144 | [1.15.x] Added entity nameplate rendering event hook (#6416) 145 | 146 | ========= 147 | Build: 1.15.1-30.0.42 - Tue Jan 21 03:47:02 GMT 2020 148 | tterrag: 149 | Remove emissive items hook, add small utility for bakedquad lighting 150 | 151 | ========= 152 | Build: 1.15.1-30.0.41 - Thu Jan 16 02:30:04 GMT 2020 153 | David Quintana: 154 | Fix breaking overlay weirdness. applyBakedNormals was not transforming the baked normals when applying them. Fixes #6432 155 | 156 | ========= 157 | Build: 1.15.1-30.0.40 - Thu Jan 16 00:30:10 GMT 2020 158 | 12281102+Aeltumn: 159 | [1.15] Add new InputEvent.ClickInputEvent, addresses #5802 (#6047) 160 | 161 | ========= 162 | Build: 1.15.1-30.0.39 - Mon Jan 13 22:21:01 GMT 2020 163 | David Quintana: 164 | Fix dark spots in fullbright quad rendering. 165 | Fix multi-layer model not declaring dependency on the particle texture. 166 | Fix mistake in 2c054fca which I didn't intend to push when I did. 167 | 168 | ========= 169 | Build: 1.15.1-30.0.38 - Mon Jan 13 18:39:06 GMT 2020 170 | David Quintana: 171 | Attempt to fix fullbright lighting. 172 | 173 | Fix lightmap value calculation. 174 | 175 | David Quintana: 176 | Fix multi-layer model loader to actually work in a sane way. No more "base" model involved, and now transforms and overrides work as expected. 177 | 178 | ========= 179 | Build: 1.15.1-30.0.36 - Thu Jan 09 22:28:02 GMT 2020 180 | tterrag: 181 | Add constructor for FishBucketItem that accepts suppliers 182 | 183 | ========= 184 | Build: 1.15.1-30.0.35 - Tue Jan 07 22:58:54 GMT 2020 185 | David Quintana: 186 | Fix QuadTransformer normal processing. 187 | 188 | Choonster.2010: 189 | Fix validation in RotationBuilder#angle (fixes #6323) (#6408) 190 | 191 | ========= 192 | Build: 1.15.1-30.0.33 - Tue Jan 07 22:20:46 GMT 2020 193 | richard: 194 | Add support for custom nether portal frame blocks (#6389) 195 | 196 | ========= 197 | Build: 1.15.1-30.0.32 - Tue Jan 07 21:22:49 GMT 2020 198 | RANKSHANK: 199 | InputEvent.RawMouseEvent fix (#6395) 200 | 201 | ========= 202 | Build: 1.15.1-30.0.31 - Tue Jan 07 21:15:19 GMT 2020 203 | DaemonUmbra: 204 | Fixed Big Mushrooms not generating (#6390) 205 | 206 | Removed vanilla negation from Forge logic that negated the vanilla logic it was replacing 207 | also ran datagen to update the dirt tag to reflect changes that were previously made in the datagen code 208 | 209 | ========= 210 | Build: 1.15.1-30.0.30 - Mon Jan 06 00:04:17 GMT 2020 211 | tterrag: 212 | Fix dyes tag containing dye items instead of tags 213 | 214 | Update generated data 215 | 216 | ========= 217 | Build: 1.15.1-30.0.29 - Sun Jan 05 19:36:08 GMT 2020 218 | Choonster.2010: 219 | [1.15.x] Remove unused parameter from ElementBuilder#rotation (fixes #6321) (#6407) 220 | 221 | ========= 222 | Build: 1.15.1-30.0.28 - Sun Jan 05 19:29:10 GMT 2020 223 | tterrag: 224 | Refactor BlockStateProvider to encapsulate a BlockModelProvider 225 | 226 | Make most protected methods of data generators public 227 | 228 | ========= 229 | Build: 1.15.1-30.0.27 - Sun Jan 05 18:39:00 GMT 2020 230 | tterrag: 231 | Fix crash when building BakedQuadBuilder 232 | 233 | Add javadocs and move sprite to constructor where possible 234 | 235 | ========= 236 | Build: 1.15.1-30.0.26 - Sun Jan 05 05:05:58 GMT 2020 237 | tterrag: 238 | Fix incorrect check for missing texture in DynamicBucketModel 239 | 240 | ========= 241 | Build: 1.15.1-30.0.25 - Sun Jan 05 04:38:48 GMT 2020 242 | tterrag: 243 | Remove custom vertex format from BakedQuad 244 | 245 | ========= 246 | Build: 1.15.1-30.0.24 - Sat Jan 04 16:19:24 GMT 2020 247 | David Quintana: 248 | Cherry-pick ca819e09 from the 1.14.x branch. Removes a patch from NativeImage which was invalid. 249 | 250 | David Quintana: 251 | A few more binary-breaking changes, before it's too late: 252 | - Move CompositeModel out of its package. 253 | - Move a few inner classes from the OBJ loader. 254 | - Rename the bucket model and fluid model classes to match the naming convention. 255 | - Remove BiomeEvent.* and WorldTypeEvent.InitBiomeGens as they are not currently implemented and they haven't been in the previous version either. 256 | 257 | ========= 258 | Build: 1.15.1-30.0.22 - Fri Jan 03 03:02:54 GMT 2020 259 | lex: 260 | Fix the particle renderer not setting GL state between each type. MC-168672 261 | 262 | ========= 263 | Build: 1.15.1-30.0.21 - Thu Jan 02 05:21:55 GMT 2020 264 | David Quintana: 265 | Fix CompositeModel not respecting "display" transforms. 266 | Remove leftovers from discarded feature. 267 | 268 | ========= 269 | Build: 1.15.1-30.0.20 - Wed Jan 01 16:41:59 GMT 2020 270 | David Quintana: 271 | Allow model jsons to override the material library used by OBJ models. 272 | Fix model loader test mod resources. 273 | Update licenses. 274 | 275 | ========= 276 | Build: 1.15.1-30.0.19 - Mon Dec 30 21:14:20 GMT 2019 277 | tterrag: 278 | Apply baked-in lightmap data to rendering 279 | 280 | - Fix ForgeHooksClient.fillNormal injecting data to lightmap 281 | - Fix OBJModel not filling lightmap data 282 | - Fix NewModelLoaderTest blockitem not linking with block 283 | 284 | ========= 285 | Build: 1.15.1-30.0.18 - Sun Dec 29 16:16:44 GMT 2019 286 | David Quintana: 287 | Fix LightUtil.unpack to set the 4th component to 1 when expanding an xyz position into a 4-component vector. 288 | Add TRSRTransformer test mod. 289 | Fix signature of the bindTileEntityRenderer method, to account for covariance. 290 | 291 | ========= 292 | Build: 1.15.1-30.0.17 - Sun Dec 29 01:16:20 GMT 2019 293 | David Quintana: 294 | More model/rendering fixes: 295 | - Breaking change: Change ClientRegistry.bindTileEntityRenderer to a factory, so mods don't have to manually specify the dispatcher. 296 | - Breaking change: Delete obsolete SimpleModelState (the class was duplicated by mistake, see SimpleModelTransform) and ICustomModelState (part of the old loader API). 297 | - Breaking change: Rename getTextureDependencies to getTextures, for consistency. 298 | - Reinstate the getRenderLayer method, fixed appropriately to return the new RenderType value. 299 | - Fix OBJ loader applying the model transform in the wrong reference frame. 300 | - Fix vanilla bug in TransformationMatrix#func_227986_a_ 301 | - Fix QuadTransformer logic. 302 | - Added new method to IModelConfiguration to retrieve the owner IUnbakedModel, needed in order to construct ItemOverrideLists when baking custom models. 303 | - Reintroduce multi-layer model through the new model loader system. 304 | 305 | ========= 306 | Build: 1.15.1-30.0.16 - Tue Dec 24 12:16:17 GMT 2019 307 | David Quintana: 308 | New batch of Model/rendering fixes: 309 | - PerspectiveMapWrapper did not pass IModelData through to the wrapped model. 310 | - CompositeModel did not store the returned textures from getTextureDependencies. 311 | - VertexFormat used COLOR instead of UV to detect UV presence. 312 | - QuadTransformer would crash due to index out of bounds. 313 | - Small cleanup of TransformationHelper 314 | 315 | ========= 316 | Build: 1.15.1-30.0.15 - Fri Dec 20 17:15:21 GMT 2019 317 | David Quintana: 318 | Fix obj models having all faces in the same mesh, breaking material assignments and visibility in the process. 319 | Reintroduce lost patch from the model loader, which would cause the custom values to be missing from generated models. 320 | 321 | ========= 322 | Build: 1.15.1-30.0.14 - Fri Dec 20 04:14:34 GMT 2019 323 | tterrag: 324 | Fix diffuse lighting being baked into models, fixes dark items 325 | 326 | ========= 327 | Build: 1.15.1-30.0.13 - Fri Dec 20 03:50:53 GMT 2019 328 | David Quintana: 329 | Fix item quads not using the existing vertex color when applying tint colors. 330 | 331 | ========= 332 | Build: 1.15.1-30.0.12 - Fri Dec 20 01:44:40 GMT 2019 333 | David Quintana: 334 | Fix bucket model. Some mask textures were not added to the repository, and the bucket override generation was broken. 335 | Fix OBJ loading crash due to a float value being parsed as int. 336 | Fixes 6377 337 | 338 | ========= 339 | Build: 1.15.1-30.0.11 - Thu Dec 19 05:56:10 GMT 2019 340 | bl4ckscor33: 341 | Fix game crashing when modded entities are present (#6364) 342 | 343 | ========= 344 | Build: 1.15.1-30.0.10 - Thu Dec 19 05:02:29 GMT 2019 345 | ichttt: 346 | Fix warning screen about missing minecraft registry entries (#6363) 347 | 348 | richard: 349 | Fix capabilities becoming inaccessible on returning from end (#6368) 350 | 351 | ========= 352 | Build: 1.15.1-30.0.8 - Thu Dec 19 04:39:52 GMT 2019 353 | ichttt: 354 | Some code cleanup for 1.15 (#6362) 355 | 356 | ========= 357 | Build: 1.15.1-30.0.7 - Wed Dec 18 02:11:01 GMT 2019 358 | tterrag: 359 | Fix MainMenuScreen patch 360 | 361 | tterrag: 362 | Mod list GUI detail pass 363 | 364 | - Make padding consistent on all elements 365 | - Properly horizontally center the "Search" text 366 | - Update and resize forge/mcp logos 367 | - Enable linear filtering on logo rendering by default 368 | - Can be disabled with the "logoBlur" mods.toml property 369 | 370 | ========= 371 | Build: 1.15.1-30.0.5 - Wed Dec 18 01:03:20 GMT 2019 372 | ichttt: 373 | Fix mod list screen (#6367) 374 | 375 | ========= 376 | Build: 1.15.1-30.0.4 - Tue Dec 17 23:47:00 GMT 2019 377 | David Quintana: 378 | Fix items in ground being too small, we were applying perspectives twice. 379 | Restore forge patch and fix a tiny mistake in it. 380 | 381 | tobias.hotz: 382 | Fix keybinds not loading/saving correctly 383 | 384 | ========= 385 | Build: 1.15.1-30.0.2 - Tue Dec 17 22:38:00 GMT 2019 386 | tterrag: 387 | Remove uvlock hook, fixes broken stair/fence/etc models 388 | 389 | tterrag: 390 | Update fallback spec version 391 | 392 | ========= 393 | Build: 1.15.1-30.0.0 - Tue Dec 17 19:42:28 GMT 2019 394 | tterrag: 395 | Update to 1.15.1 396 | 397 | ========= 398 | Build: 1.15-29.0.4 - Tue Dec 17 18:15:10 GMT 2019 399 | David Quintana: 400 | Finish converting the code from javax.vecmath to the vanilla vector classes. Forge is now vecmath-free! 401 | 402 | ========= 403 | Build: 1.15-29.0.3 - Tue Dec 17 09:50:53 GMT 2019 404 | tterrag: 405 | Remove deprecations 406 | 407 | ========= 408 | Build: 1.15-29.0.2 - Tue Dec 17 04:47:01 GMT 2019 409 | tterrag: 410 | Fix incorrect item lighting 411 | 412 | ========= 413 | Build: 1.15-29.0.1 - Tue Dec 17 04:22:29 GMT 2019 414 | tterrag: 415 | Revert fluid change to use Material, fixes server crash 416 | -------------------------------------------------------------------------------- /src/main/java/com/mrcrayfish/improvedwolves/entity/ai/goal/PutInChestGoal.java: -------------------------------------------------------------------------------- 1 | package com.mrcrayfish.improvedwolves.entity.ai.goal; 2 | 3 | import com.mrcrayfish.improvedwolves.common.entity.PlayerDataHandler; 4 | import com.mrcrayfish.improvedwolves.common.entity.WolfHeldItemDataHandler; 5 | import com.mrcrayfish.improvedwolves.init.ModMemoryModuleTypes; 6 | import com.mrcrayfish.improvedwolves.network.PacketHandler; 7 | import com.mrcrayfish.improvedwolves.network.message.MessageSyncHeldWolfItem; 8 | import com.mrcrayfish.improvedwolves.util.InventoryUtil; 9 | import com.mrcrayfish.improvedwolves.util.TileEntityUtil; 10 | import net.minecraft.block.BlockState; 11 | import net.minecraft.block.LeavesBlock; 12 | import net.minecraft.entity.LivingEntity; 13 | import net.minecraft.entity.ai.goal.Goal; 14 | import net.minecraft.entity.item.ItemEntity; 15 | import net.minecraft.entity.passive.WolfEntity; 16 | import net.minecraft.entity.player.PlayerEntity; 17 | import net.minecraft.entity.player.PlayerInventory; 18 | import net.minecraft.inventory.IInventory; 19 | import net.minecraft.item.ItemStack; 20 | import net.minecraft.pathfinding.PathNodeType; 21 | import net.minecraft.pathfinding.WalkNodeProcessor; 22 | import net.minecraft.tileentity.TileEntity; 23 | import net.minecraft.util.SoundCategory; 24 | import net.minecraft.util.SoundEvents; 25 | import net.minecraft.util.math.BlockPos; 26 | import net.minecraft.util.math.GlobalPos; 27 | import net.minecraft.util.math.MathHelper; 28 | import net.minecraftforge.fml.network.PacketDistributor; 29 | 30 | import java.util.EnumSet; 31 | import java.util.Optional; 32 | 33 | /** 34 | * Author: MrCrayfish 35 | */ 36 | public class PutInChestGoal extends Goal 37 | { 38 | private State state = State.FINISHED; 39 | private WolfEntity entity; 40 | private LivingEntity owner; 41 | private GlobalPos globalPos; 42 | private IInventory inventory; 43 | private TileEntity tileEntity; 44 | 45 | public PutInChestGoal(WolfEntity entity) 46 | { 47 | this.entity = entity; 48 | this.setMutexFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.JUMP, Flag.LOOK)); 49 | } 50 | 51 | @Override 52 | public boolean shouldExecute() 53 | { 54 | if(!this.entity.isTamed() || this.entity.isSitting() || !this.entity.getBrain().hasMemory(ModMemoryModuleTypes.CHEST)) 55 | { 56 | return false; 57 | } 58 | LivingEntity owner = this.entity.getOwner(); 59 | if(owner == null) 60 | { 61 | return false; 62 | } 63 | GlobalPos globalPos = this.entity.getBrain().getMemory(ModMemoryModuleTypes.CHEST).orElse(null); 64 | if(globalPos == null) 65 | { 66 | return false; 67 | } 68 | ItemStack heldItem = owner.getHeldItemMainhand(); 69 | if(heldItem.isEmpty()) 70 | { 71 | return false; 72 | } 73 | TileEntity tileEntity = this.getStorage(globalPos.getPos()); 74 | if(tileEntity == null) 75 | { 76 | return false; 77 | } 78 | if(canInsertItemIntoStorage((IInventory) tileEntity, heldItem)) 79 | { 80 | this.globalPos = globalPos; 81 | this.inventory = (IInventory) tileEntity; 82 | this.owner = owner; 83 | this.state = State.GET_ITEM_FROM_PLAYER; 84 | this.tileEntity = tileEntity; 85 | return true; 86 | } 87 | return false; 88 | } 89 | 90 | @Override 91 | public void tick() 92 | { 93 | switch(this.state) 94 | { 95 | case GET_ITEM_FROM_PLAYER: 96 | if(this.tileEntity.isRemoved()) 97 | { 98 | this.state = State.FINISHED; 99 | return; 100 | } 101 | 102 | Optional optional = this.entity.getBrain().getMemory(ModMemoryModuleTypes.CHEST); 103 | if(!optional.isPresent()) 104 | { 105 | this.state = State.GIVE_ITEM_TO_PLAYER; 106 | return; 107 | } 108 | 109 | if(!this.owner.isAlive()) 110 | { 111 | this.state = State.FINISHED; 112 | return; 113 | } 114 | 115 | ItemStack heldItem = this.owner.getHeldItemMainhand(); 116 | if(heldItem.isEmpty()) 117 | { 118 | this.state = State.FINISHED; 119 | return; 120 | } 121 | 122 | if(this.entity.getDistance(this.owner) >= 2.0) 123 | { 124 | this.entity.getLookController().setLookPositionWithEntity(this.owner, 30F, 30F); 125 | if(!this.entity.getNavigator().tryMoveToEntityLiving(this.owner, 1)) 126 | { 127 | this.state = State.FINISHED; 128 | return; 129 | } 130 | } 131 | else 132 | { 133 | WolfHeldItemDataHandler.IWolfHeldItem handler = WolfHeldItemDataHandler.getHandler(this.entity); 134 | if(handler != null) 135 | { 136 | int maxCount = getMaxInsertCount(this.inventory, heldItem); 137 | ItemStack copy = heldItem.copy(); 138 | copy.setCount(Math.min(maxCount, copy.getCount())); 139 | handler.setItemStack(copy); 140 | PacketHandler.instance.send(PacketDistributor.TRACKING_ENTITY.with(() -> this.entity), new MessageSyncHeldWolfItem(this.entity.getEntityId(), handler.getItemStack())); 141 | heldItem.shrink(copy.getCount()); 142 | this.state = State.PUT_ITEM_IN_CHEST; 143 | this.entity.world.playSound(null, this.entity.getPosX(), this.entity.getPosY() + this.entity.getEyeHeight(), this.entity.getPosZ(), SoundEvents.ENTITY_FOX_BITE, SoundCategory.NEUTRAL, 1.0F, 0.5F); 144 | return; 145 | } 146 | } 147 | this.state = State.FINISHED; 148 | break; 149 | case PUT_ITEM_IN_CHEST: 150 | if(this.tileEntity.isRemoved()) 151 | { 152 | this.state = State.GIVE_ITEM_TO_PLAYER; 153 | return; 154 | } 155 | 156 | WolfHeldItemDataHandler.IWolfHeldItem handler = WolfHeldItemDataHandler.getHandler(this.entity); 157 | if(handler != null) 158 | { 159 | ItemStack stack = handler.getItemStack(); 160 | if(!stack.isEmpty()) 161 | { 162 | Optional optional2 = this.entity.getBrain().getMemory(ModMemoryModuleTypes.CHEST); 163 | if(!optional2.isPresent()) 164 | { 165 | this.entity.getNavigator().clearPath(); 166 | this.state = State.GIVE_ITEM_TO_PLAYER; 167 | return; 168 | } 169 | 170 | this.updateTargetChest(stack); 171 | 172 | if(canInsertItemIntoStorage(this.inventory, stack)) 173 | { 174 | if(!this.globalPos.getPos().withinDistance(this.entity.getPositionVec(), 1.5)) 175 | { 176 | this.entity.getLookController().setLookPosition(this.globalPos.getPos().getX() + 0.5, this.globalPos.getPos().getY() + 0.5, this.globalPos.getPos().getZ() + 0.5); 177 | if(!this.entity.getNavigator().tryMoveToXYZ(this.globalPos.getPos().getX() + 0.5, this.globalPos.getPos().getY(), this.globalPos.getPos().getZ() + 0.5, 1.0)) 178 | { 179 | this.state = State.GIVE_ITEM_TO_PLAYER; 180 | return; 181 | } 182 | return; 183 | } 184 | else 185 | { 186 | ItemStack copy = stack.copy(); 187 | addItemStackToInventory(this.inventory, copy); 188 | if(!copy.isEmpty()) 189 | { 190 | this.state = State.GIVE_ITEM_TO_PLAYER; 191 | } 192 | else 193 | { 194 | this.state = State.MOVE_TO_PLAYER; 195 | } 196 | handler.setItemStack(copy); 197 | PacketHandler.instance.send(PacketDistributor.TRACKING_ENTITY.with(() -> this.entity), new MessageSyncHeldWolfItem(this.entity.getEntityId(), handler.getItemStack())); 198 | this.entity.getBrain().removeMemory(ModMemoryModuleTypes.CHEST); 199 | this.entity.world.playSound(null, this.entity.getPosX(), this.entity.getPosY() + this.entity.getEyeHeight(), this.entity.getPosZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.NEUTRAL, 1.0F, 0.5F); 200 | if(this.inventory instanceof TileEntity) 201 | { 202 | TileEntityUtil.sendUpdatePacket((TileEntity) this.inventory); 203 | } 204 | return; 205 | } 206 | } 207 | else 208 | { 209 | this.state = State.GIVE_ITEM_TO_PLAYER; 210 | return; 211 | } 212 | } 213 | } 214 | this.state = State.FINISHED; 215 | break; 216 | case GIVE_ITEM_TO_PLAYER: 217 | WolfHeldItemDataHandler.IWolfHeldItem handler2 = WolfHeldItemDataHandler.getHandler(this.entity); 218 | if(handler2 != null) 219 | { 220 | ItemStack stack = handler2.getItemStack(); 221 | if(!stack.isEmpty()) 222 | { 223 | if(!this.owner.isAlive()) 224 | { 225 | this.state = State.FINISHED; 226 | PacketHandler.instance.send(PacketDistributor.TRACKING_ENTITY.with(() -> this.entity), new MessageSyncHeldWolfItem(this.entity.getEntityId(), handler2.getItemStack())); 227 | handler2.setItemStack(ItemStack.EMPTY); 228 | this.entity.getEntityWorld().addEntity(new ItemEntity(this.entity.world, this.entity.getPosX(), this.entity.getPosY(), this.entity.getPosZ(), stack.copy())); 229 | return; 230 | } 231 | 232 | this.updateTargetChest(stack); 233 | 234 | Optional optional2 = this.entity.getBrain().getMemory(ModMemoryModuleTypes.CHEST); 235 | if(optional2.isPresent() && canInsertItemIntoStorage(this.inventory, stack)) 236 | { 237 | this.state = State.PUT_ITEM_IN_CHEST; 238 | return; 239 | } 240 | else if(this.entity.getDistance(this.owner) > 2.0) 241 | { 242 | this.entity.getLookController().setLookPositionWithEntity(this.owner, 30F, 30F); 243 | if(this.entity.getNavigator().tryMoveToEntityLiving(this.owner, 1)) 244 | { 245 | if(this.entity.getDistanceSq(this.owner) >= 144.0D) 246 | { 247 | this.moveToPlayer(); 248 | } 249 | return; 250 | } 251 | return; 252 | } 253 | else 254 | { 255 | if(this.owner instanceof PlayerEntity) 256 | { 257 | PlayerInventory playerInventory = ((PlayerEntity) this.owner).inventory; 258 | playerInventory.placeItemBackInInventory(this.owner.world, stack); 259 | PacketHandler.instance.send(PacketDistributor.TRACKING_ENTITY.with(() -> this.entity), new MessageSyncHeldWolfItem(this.entity.getEntityId(), handler2.getItemStack())); 260 | handler2.setItemStack(ItemStack.EMPTY); 261 | if(this.owner instanceof PlayerEntity) 262 | { 263 | PlayerDataHandler.IPlayerData playerDataHandler = PlayerDataHandler.getHandler((PlayerEntity) this.owner); 264 | if(playerDataHandler != null) 265 | { 266 | playerDataHandler.setCommandingWolf(null); 267 | } 268 | } 269 | this.state = State.FINISHED; 270 | this.entity.world.playSound(null, this.entity.getPosX(), this.entity.getPosY() + this.entity.getEyeHeight(), this.entity.getPosZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.NEUTRAL, 1.0F, 1.0F); 271 | return; 272 | } 273 | } 274 | } 275 | } 276 | this.state = State.FINISHED; 277 | break; 278 | case MOVE_TO_PLAYER: 279 | if(this.entity.getDistance(this.owner) > 2.0) 280 | { 281 | this.entity.getLookController().setLookPositionWithEntity(this.owner, 30F, 30F); 282 | if(!this.entity.getNavigator().tryMoveToEntityLiving(this.owner, 1)) 283 | { 284 | if(this.entity.getDistanceSq(this.owner) >= 144.0D) 285 | { 286 | this.moveToPlayer(); 287 | } 288 | } 289 | } 290 | else 291 | { 292 | Optional optional3 = this.entity.getBrain().getMemory(ModMemoryModuleTypes.CHEST); 293 | if(optional3.isPresent()) 294 | { 295 | ItemStack heldItem2 = this.owner.getHeldItemMainhand(); 296 | if(!heldItem2.isEmpty()) 297 | { 298 | this.updateTargetChest(heldItem2); 299 | if(canInsertItemIntoStorage(this.inventory, heldItem2)) 300 | { 301 | this.state = State.PUT_ITEM_IN_CHEST; 302 | return; 303 | } 304 | } 305 | } 306 | this.state = State.FINISHED; 307 | } 308 | break; 309 | case FINISHED: 310 | WolfHeldItemDataHandler.IWolfHeldItem handler1 = WolfHeldItemDataHandler.getHandler(this.entity); 311 | if(handler1 != null) 312 | { 313 | ItemStack stack = handler1.getItemStack(); 314 | if(!stack.isEmpty()) 315 | { 316 | 317 | } 318 | } 319 | break; 320 | } 321 | } 322 | 323 | @Override 324 | public boolean shouldContinueExecuting() 325 | { 326 | return this.state != State.FINISHED && this.owner.isAlive(); 327 | } 328 | 329 | @Override 330 | public void resetTask() 331 | { 332 | this.state = State.FINISHED; 333 | if(this.owner instanceof PlayerEntity) 334 | { 335 | PlayerDataHandler.IPlayerData playerDataHandler = PlayerDataHandler.getHandler((PlayerEntity) this.owner); 336 | if(playerDataHandler != null) 337 | { 338 | playerDataHandler.setCommandingWolf(null); 339 | } 340 | } 341 | this.owner = null; 342 | this.inventory = null; 343 | this.globalPos = null; 344 | this.tileEntity = null; 345 | } 346 | 347 | private TileEntity getStorage(BlockPos pos) 348 | { 349 | TileEntity tileEntity = this.entity.getEntityWorld().getTileEntity(pos); 350 | if(tileEntity instanceof IInventory) 351 | { 352 | return tileEntity; 353 | } 354 | return null; 355 | } 356 | 357 | public static boolean canInsertItemIntoStorage(IInventory inventory, ItemStack stack) //TODO test this 358 | { 359 | for(int i = 0; i < inventory.getSizeInventory(); i++) 360 | { 361 | if(inventory.isItemValidForSlot(i, stack)) 362 | { 363 | ItemStack slotStack = inventory.getStackInSlot(i); 364 | if(slotStack.isEmpty()) 365 | { 366 | return true; 367 | } 368 | if(InventoryUtil.areItemStackEqualIgnoreCount(slotStack, stack)) 369 | { 370 | if(slotStack.getCount() < slotStack.getMaxStackSize()) 371 | { 372 | return true; 373 | } 374 | } 375 | } 376 | } 377 | return false; 378 | } 379 | 380 | public static int getMaxInsertCount(IInventory inventory, ItemStack stack) 381 | { 382 | int count = 0; 383 | for(int i = 0; i < inventory.getSizeInventory(); i++) 384 | { 385 | if(inventory.isItemValidForSlot(i, stack)) 386 | { 387 | ItemStack slotStack = inventory.getStackInSlot(i); 388 | if(slotStack.isEmpty()) 389 | { 390 | count += stack.getMaxStackSize(); 391 | } 392 | if(InventoryUtil.areItemStackEqualIgnoreCount(slotStack, stack)) 393 | { 394 | count += slotStack.getMaxStackSize() - slotStack.getCount(); 395 | } 396 | } 397 | } 398 | return MathHelper.clamp(count, 0, 64); 399 | } 400 | 401 | public static void addItemStackToInventory(IInventory inventory, ItemStack stack) 402 | { 403 | for(int i = 0; i < inventory.getSizeInventory(); i++) 404 | { 405 | if(stack.isEmpty()) 406 | { 407 | return; 408 | } 409 | if(inventory.isItemValidForSlot(i, stack)) 410 | { 411 | ItemStack slotStack = inventory.getStackInSlot(i); 412 | if(slotStack.isEmpty()) 413 | { 414 | inventory.setInventorySlotContents(i, stack.copy()); 415 | stack.setCount(0); 416 | return; 417 | } 418 | if(InventoryUtil.areItemStackEqualIgnoreCount(slotStack, stack)) 419 | { 420 | if(slotStack.getCount() < slotStack.getMaxStackSize()) 421 | { 422 | int deltaCount = slotStack.getMaxStackSize() - slotStack.getCount(); 423 | int minCount = Math.min(deltaCount, stack.getCount()); 424 | slotStack.grow(minCount); 425 | stack.shrink(minCount); 426 | } 427 | } 428 | } 429 | } 430 | } 431 | 432 | private void updateTargetChest(ItemStack stack) 433 | { 434 | Optional optional = this.entity.getBrain().getMemory(ModMemoryModuleTypes.CHEST); 435 | if(optional.isPresent()) 436 | { 437 | GlobalPos newPos = optional.get(); 438 | if(!newPos.equals(this.globalPos)) 439 | { 440 | TileEntity tileEntity = this.getStorage(newPos.getPos()); 441 | if(tileEntity != null) 442 | { 443 | if(canInsertItemIntoStorage((IInventory) tileEntity, stack)) 444 | { 445 | this.globalPos = newPos; 446 | this.inventory = (IInventory) tileEntity; 447 | this.tileEntity = tileEntity; 448 | } 449 | } 450 | } 451 | } 452 | } 453 | 454 | private void moveToPlayer() 455 | { 456 | BlockPos pos = new BlockPos(this.owner); 457 | for(int i = 0; i < 10; i++) 458 | { 459 | int offsetX = this.getRandomOffset(-3, 3); 460 | int offsetY = this.getRandomOffset(-1, 1); 461 | int offsetZ = this.getRandomOffset(-3, 3); 462 | boolean moved = this.moveToPlayer(pos.getX() + offsetX, pos.getY() + offsetY, pos.getZ() + offsetZ); 463 | if(moved) 464 | { 465 | return; 466 | } 467 | } 468 | } 469 | 470 | private int getRandomOffset(int min, int max) 471 | { 472 | return this.entity.getRNG().nextInt(max - min + 1) + min; 473 | } 474 | 475 | private boolean moveToPlayer(int posX, int posY, int posZ) 476 | { 477 | if(Math.abs((double) posX - this.owner.getPosX()) < 2.0D && Math.abs((double) posZ - this.owner.getPosZ()) < 2.0D) 478 | { 479 | return false; 480 | } 481 | else if(!this.isValidPos(new BlockPos(posX, posY, posZ))) 482 | { 483 | return false; 484 | } 485 | else 486 | { 487 | this.entity.setLocationAndAngles((double) ((float) posX + 0.5F), (double) posY, (double) ((float) posZ + 0.5F), this.entity.rotationYaw, this.entity.rotationPitch); 488 | this.entity.getNavigator().clearPath(); 489 | return true; 490 | } 491 | } 492 | 493 | private boolean isValidPos(BlockPos pos) 494 | { 495 | PathNodeType pathNodeType = WalkNodeProcessor.func_227480_b_(this.entity.world, pos.getX(), pos.getY(), pos.getZ()); 496 | if(pathNodeType != PathNodeType.WALKABLE) 497 | { 498 | return false; 499 | } 500 | 501 | BlockState state = this.entity.world.getBlockState(pos.down()); 502 | if(state.getBlock() instanceof LeavesBlock) 503 | { 504 | return false; 505 | } 506 | else 507 | { 508 | BlockPos entityPos = pos.subtract(new BlockPos(this.entity)); 509 | return this.entity.world.func_226665_a__(this.entity, this.entity.getBoundingBox().offset(entityPos)); 510 | } 511 | } 512 | 513 | public enum State 514 | { 515 | GET_ITEM_FROM_PLAYER, 516 | PUT_ITEM_IN_CHEST, 517 | GIVE_ITEM_TO_PLAYER, 518 | MOVE_TO_PLAYER, 519 | FINISHED; 520 | } 521 | } 522 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Unless noted below, Minecraft Forge, Forge Mod Loader, and all 2 | parts herein are licensed under the terms of the LGPL 2.1 found 3 | here http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt and 4 | copied below. 5 | 6 | Homepage: http://minecraftforge.net/ 7 | https://github.com/MinecraftForge/MinecraftForge 8 | 9 | 10 | A note on authorship: 11 | All source artifacts are property of their original author, with 12 | the exclusion of the contents of the patches directory and others 13 | copied from it from time to time. Authorship of the contents of 14 | the patches directory is retained by the Minecraft Forge project. 15 | This is because the patches are partially machine generated 16 | artifacts, and are changed heavily due to the way forge works. 17 | Individual attribution within them is impossible. 18 | 19 | Consent: 20 | All contributions to Forge must consent to the release of any 21 | patch content to the Forge project. 22 | 23 | A note on infectivity: 24 | The LGPL is chosen specifically so that projects may depend on Forge 25 | features without being infected with its license. That is the 26 | purpose of the LGPL. Mods and others using this code via ordinary 27 | Java mechanics for referencing libraries are specifically not bound 28 | by Forge's license for the Mod code. 29 | 30 | 31 | === MCP Data === 32 | This software includes data from the Minecraft Coder Pack (MCP), with kind permission 33 | from them. The license to MCP data is not transitive - distribution of this data by 34 | third parties requires independent licensing from the MCP team. This data is not 35 | redistributable without permission from the MCP team. 36 | 37 | === Sharing === 38 | I grant permission for some parts of FML to be redistributed outside the terms of the LGPL, for the benefit of 39 | the minecraft modding community. All contributions to these parts should be licensed under the same additional grant. 40 | 41 | -- Runtime patcher -- 42 | License is granted to redistribute the runtime patcher code (src/main/java/net/minecraftforge/fml/common/patcher 43 | and subdirectories) under any alternative open source license as classified by the OSI (http://opensource.org/licenses) 44 | 45 | -- ASM transformers -- 46 | License is granted to redistribute the ASM transformer code (src/main/java/net/minecraftforge/common/asm/ and subdirectories) 47 | under any alternative open source license as classified by the OSI (http://opensource.org/licenses) 48 | 49 | ========================================================================= 50 | This software includes portions from the Apache Maven project at 51 | http://maven.apache.org/ specifically the ComparableVersion.java code. It is 52 | included based on guidelines at 53 | http://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html 54 | with notices intact. The only change is a non-functional change of package name. 55 | 56 | This software contains a partial repackaging of javaxdelta, a BSD licensed program for generating 57 | binary differences and applying them, sourced from the subversion at http://sourceforge.net/projects/javaxdelta/ 58 | authored by genman, heikok, pivot. 59 | The only changes are to replace some Trove collection types with standard Java collections, and repackaged. 60 | ========================================================================= 61 | 62 | 63 | GNU LESSER GENERAL PUBLIC LICENSE 64 | Version 2.1, February 1999 65 | 66 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 67 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 68 | Everyone is permitted to copy and distribute verbatim copies 69 | of this license document, but changing it is not allowed. 70 | 71 | [This is the first released version of the Lesser GPL. It also counts 72 | as the successor of the GNU Library Public License, version 2, hence 73 | the version number 2.1.] 74 | 75 | Preamble 76 | 77 | The licenses for most software are designed to take away your 78 | freedom to share and change it. By contrast, the GNU General Public 79 | Licenses are intended to guarantee your freedom to share and change 80 | free software--to make sure the software is free for all its users. 81 | 82 | This license, the Lesser General Public License, applies to some 83 | specially designated software packages--typically libraries--of the 84 | Free Software Foundation and other authors who decide to use it. You 85 | can use it too, but we suggest you first think carefully about whether 86 | this license or the ordinary General Public License is the better 87 | strategy to use in any particular case, based on the explanations below. 88 | 89 | When we speak of free software, we are referring to freedom of use, 90 | not price. Our General Public Licenses are designed to make sure that 91 | you have the freedom to distribute copies of free software (and charge 92 | for this service if you wish); that you receive source code or can get 93 | it if you want it; that you can change the software and use pieces of 94 | it in new free programs; and that you are informed that you can do 95 | these things. 96 | 97 | To protect your rights, we need to make restrictions that forbid 98 | distributors to deny you these rights or to ask you to surrender these 99 | rights. These restrictions translate to certain responsibilities for 100 | you if you distribute copies of the library or if you modify it. 101 | 102 | For example, if you distribute copies of the library, whether gratis 103 | or for a fee, you must give the recipients all the rights that we gave 104 | you. You must make sure that they, too, receive or can get the source 105 | code. If you link other code with the library, you must provide 106 | complete object files to the recipients, so that they can relink them 107 | with the library after making changes to the library and recompiling 108 | it. And you must show them these terms so they know their rights. 109 | 110 | We protect your rights with a two-step method: (1) we copyright the 111 | library, and (2) we offer you this license, which gives you legal 112 | permission to copy, distribute and/or modify the library. 113 | 114 | To protect each distributor, we want to make it very clear that 115 | there is no warranty for the free library. Also, if the library is 116 | modified by someone else and passed on, the recipients should know 117 | that what they have is not the original version, so that the original 118 | author's reputation will not be affected by problems that might be 119 | introduced by others. 120 | 121 | Finally, software patents pose a constant threat to the existence of 122 | any free program. We wish to make sure that a company cannot 123 | effectively restrict the users of a free program by obtaining a 124 | restrictive license from a patent holder. Therefore, we insist that 125 | any patent license obtained for a version of the library must be 126 | consistent with the full freedom of use specified in this license. 127 | 128 | Most GNU software, including some libraries, is covered by the 129 | ordinary GNU General Public License. This license, the GNU Lesser 130 | General Public License, applies to certain designated libraries, and 131 | is quite different from the ordinary General Public License. We use 132 | this license for certain libraries in order to permit linking those 133 | libraries into non-free programs. 134 | 135 | When a program is linked with a library, whether statically or using 136 | a shared library, the combination of the two is legally speaking a 137 | combined work, a derivative of the original library. The ordinary 138 | General Public License therefore permits such linking only if the 139 | entire combination fits its criteria of freedom. The Lesser General 140 | Public License permits more lax criteria for linking other code with 141 | the library. 142 | 143 | We call this license the "Lesser" General Public License because it 144 | does Less to protect the user's freedom than the ordinary General 145 | Public License. It also provides other free software developers Less 146 | of an advantage over competing non-free programs. These disadvantages 147 | are the reason we use the ordinary General Public License for many 148 | libraries. However, the Lesser license provides advantages in certain 149 | special circumstances. 150 | 151 | For example, on rare occasions, there may be a special need to 152 | encourage the widest possible use of a certain library, so that it becomes 153 | a de-facto standard. To achieve this, non-free programs must be 154 | allowed to use the library. A more frequent case is that a free 155 | library does the same job as widely used non-free libraries. In this 156 | case, there is little to gain by limiting the free library to free 157 | software only, so we use the Lesser General Public License. 158 | 159 | In other cases, permission to use a particular library in non-free 160 | programs enables a greater number of people to use a large body of 161 | free software. For example, permission to use the GNU C Library in 162 | non-free programs enables many more people to use the whole GNU 163 | operating system, as well as its variant, the GNU/Linux operating 164 | system. 165 | 166 | Although the Lesser General Public License is Less protective of the 167 | users' freedom, it does ensure that the user of a program that is 168 | linked with the Library has the freedom and the wherewithal to run 169 | that program using a modified version of the Library. 170 | 171 | The precise terms and conditions for copying, distribution and 172 | modification follow. Pay close attention to the difference between a 173 | "work based on the library" and a "work that uses the library". The 174 | former contains code derived from the library, whereas the latter must 175 | be combined with the library in order to run. 176 | 177 | GNU LESSER GENERAL PUBLIC LICENSE 178 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 179 | 180 | 0. This License Agreement applies to any software library or other 181 | program which contains a notice placed by the copyright holder or 182 | other authorized party saying it may be distributed under the terms of 183 | this Lesser General Public License (also called "this License"). 184 | Each licensee is addressed as "you". 185 | 186 | A "library" means a collection of software functions and/or data 187 | prepared so as to be conveniently linked with application programs 188 | (which use some of those functions and data) to form executables. 189 | 190 | The "Library", below, refers to any such software library or work 191 | which has been distributed under these terms. A "work based on the 192 | Library" means either the Library or any derivative work under 193 | copyright law: that is to say, a work containing the Library or a 194 | portion of it, either verbatim or with modifications and/or translated 195 | straightforwardly into another language. (Hereinafter, translation is 196 | included without limitation in the term "modification".) 197 | 198 | "Source code" for a work means the preferred form of the work for 199 | making modifications to it. For a library, complete source code means 200 | all the source code for all modules it contains, plus any associated 201 | interface definition files, plus the scripts used to control compilation 202 | and installation of the library. 203 | 204 | Activities other than copying, distribution and modification are not 205 | covered by this License; they are outside its scope. The act of 206 | running a program using the Library is not restricted, and output from 207 | such a program is covered only if its contents constitute a work based 208 | on the Library (independent of the use of the Library in a tool for 209 | writing it). Whether that is true depends on what the Library does 210 | and what the program that uses the Library does. 211 | 212 | 1. You may copy and distribute verbatim copies of the Library's 213 | complete source code as you receive it, in any medium, provided that 214 | you conspicuously and appropriately publish on each copy an 215 | appropriate copyright notice and disclaimer of warranty; keep intact 216 | all the notices that refer to this License and to the absence of any 217 | warranty; and distribute a copy of this License along with the 218 | Library. 219 | 220 | You may charge a fee for the physical act of transferring a copy, 221 | and you may at your option offer warranty protection in exchange for a 222 | fee. 223 | 224 | 2. You may modify your copy or copies of the Library or any portion 225 | of it, thus forming a work based on the Library, and copy and 226 | distribute such modifications or work under the terms of Section 1 227 | above, provided that you also meet all of these conditions: 228 | 229 | a) The modified work must itself be a software library. 230 | 231 | b) You must cause the files modified to carry prominent notices 232 | stating that you changed the files and the date of any change. 233 | 234 | c) You must cause the whole of the work to be licensed at no 235 | charge to all third parties under the terms of this License. 236 | 237 | d) If a facility in the modified Library refers to a function or a 238 | table of data to be supplied by an application program that uses 239 | the facility, other than as an argument passed when the facility 240 | is invoked, then you must make a good faith effort to ensure that, 241 | in the event an application does not supply such function or 242 | table, the facility still operates, and performs whatever part of 243 | its purpose remains meaningful. 244 | 245 | (For example, a function in a library to compute square roots has 246 | a purpose that is entirely well-defined independent of the 247 | application. Therefore, Subsection 2d requires that any 248 | application-supplied function or table used by this function must 249 | be optional: if the application does not supply it, the square 250 | root function must still compute square roots.) 251 | 252 | These requirements apply to the modified work as a whole. If 253 | identifiable sections of that work are not derived from the Library, 254 | and can be reasonably considered independent and separate works in 255 | themselves, then this License, and its terms, do not apply to those 256 | sections when you distribute them as separate works. But when you 257 | distribute the same sections as part of a whole which is a work based 258 | on the Library, the distribution of the whole must be on the terms of 259 | this License, whose permissions for other licensees extend to the 260 | entire whole, and thus to each and every part regardless of who wrote 261 | it. 262 | 263 | Thus, it is not the intent of this section to claim rights or contest 264 | your rights to work written entirely by you; rather, the intent is to 265 | exercise the right to control the distribution of derivative or 266 | collective works based on the Library. 267 | 268 | In addition, mere aggregation of another work not based on the Library 269 | with the Library (or with a work based on the Library) on a volume of 270 | a storage or distribution medium does not bring the other work under 271 | the scope of this License. 272 | 273 | 3. You may opt to apply the terms of the ordinary GNU General Public 274 | License instead of this License to a given copy of the Library. To do 275 | this, you must alter all the notices that refer to this License, so 276 | that they refer to the ordinary GNU General Public License, version 2, 277 | instead of to this License. (If a newer version than version 2 of the 278 | ordinary GNU General Public License has appeared, then you can specify 279 | that version instead if you wish.) Do not make any other change in 280 | these notices. 281 | 282 | Once this change is made in a given copy, it is irreversible for 283 | that copy, so the ordinary GNU General Public License applies to all 284 | subsequent copies and derivative works made from that copy. 285 | 286 | This option is useful when you wish to copy part of the code of 287 | the Library into a program that is not a library. 288 | 289 | 4. You may copy and distribute the Library (or a portion or 290 | derivative of it, under Section 2) in object code or executable form 291 | under the terms of Sections 1 and 2 above provided that you accompany 292 | it with the complete corresponding machine-readable source code, which 293 | must be distributed under the terms of Sections 1 and 2 above on a 294 | medium customarily used for software interchange. 295 | 296 | If distribution of object code is made by offering access to copy 297 | from a designated place, then offering equivalent access to copy the 298 | source code from the same place satisfies the requirement to 299 | distribute the source code, even though third parties are not 300 | compelled to copy the source along with the object code. 301 | 302 | 5. A program that contains no derivative of any portion of the 303 | Library, but is designed to work with the Library by being compiled or 304 | linked with it, is called a "work that uses the Library". Such a 305 | work, in isolation, is not a derivative work of the Library, and 306 | therefore falls outside the scope of this License. 307 | 308 | However, linking a "work that uses the Library" with the Library 309 | creates an executable that is a derivative of the Library (because it 310 | contains portions of the Library), rather than a "work that uses the 311 | library". The executable is therefore covered by this License. 312 | Section 6 states terms for distribution of such executables. 313 | 314 | When a "work that uses the Library" uses material from a header file 315 | that is part of the Library, the object code for the work may be a 316 | derivative work of the Library even though the source code is not. 317 | Whether this is true is especially significant if the work can be 318 | linked without the Library, or if the work is itself a library. The 319 | threshold for this to be true is not precisely defined by law. 320 | 321 | If such an object file uses only numerical parameters, data 322 | structure layouts and accessors, and small macros and small inline 323 | functions (ten lines or less in length), then the use of the object 324 | file is unrestricted, regardless of whether it is legally a derivative 325 | work. (Executables containing this object code plus portions of the 326 | Library will still fall under Section 6.) 327 | 328 | Otherwise, if the work is a derivative of the Library, you may 329 | distribute the object code for the work under the terms of Section 6. 330 | Any executables containing that work also fall under Section 6, 331 | whether or not they are linked directly with the Library itself. 332 | 333 | 6. As an exception to the Sections above, you may also combine or 334 | link a "work that uses the Library" with the Library to produce a 335 | work containing portions of the Library, and distribute that work 336 | under terms of your choice, provided that the terms permit 337 | modification of the work for the customer's own use and reverse 338 | engineering for debugging such modifications. 339 | 340 | You must give prominent notice with each copy of the work that the 341 | Library is used in it and that the Library and its use are covered by 342 | this License. You must supply a copy of this License. If the work 343 | during execution displays copyright notices, you must include the 344 | copyright notice for the Library among them, as well as a reference 345 | directing the user to the copy of this License. Also, you must do one 346 | of these things: 347 | 348 | a) Accompany the work with the complete corresponding 349 | machine-readable source code for the Library including whatever 350 | changes were used in the work (which must be distributed under 351 | Sections 1 and 2 above); and, if the work is an executable linked 352 | with the Library, with the complete machine-readable "work that 353 | uses the Library", as object code and/or source code, so that the 354 | user can modify the Library and then relink to produce a modified 355 | executable containing the modified Library. (It is understood 356 | that the user who changes the contents of definitions files in the 357 | Library will not necessarily be able to recompile the application 358 | to use the modified definitions.) 359 | 360 | b) Use a suitable shared library mechanism for linking with the 361 | Library. A suitable mechanism is one that (1) uses at run time a 362 | copy of the library already present on the user's computer system, 363 | rather than copying library functions into the executable, and (2) 364 | will operate properly with a modified version of the library, if 365 | the user installs one, as long as the modified version is 366 | interface-compatible with the version that the work was made with. 367 | 368 | c) Accompany the work with a written offer, valid for at 369 | least three years, to give the same user the materials 370 | specified in Subsection 6a, above, for a charge no more 371 | than the cost of performing this distribution. 372 | 373 | d) If distribution of the work is made by offering access to copy 374 | from a designated place, offer equivalent access to copy the above 375 | specified materials from the same place. 376 | 377 | e) Verify that the user has already received a copy of these 378 | materials or that you have already sent this user a copy. 379 | 380 | For an executable, the required form of the "work that uses the 381 | Library" must include any data and utility programs needed for 382 | reproducing the executable from it. However, as a special exception, 383 | the materials to be distributed need not include anything that is 384 | normally distributed (in either source or binary form) with the major 385 | components (compiler, kernel, and so on) of the operating system on 386 | which the executable runs, unless that component itself accompanies 387 | the executable. 388 | 389 | It may happen that this requirement contradicts the license 390 | restrictions of other proprietary libraries that do not normally 391 | accompany the operating system. Such a contradiction means you cannot 392 | use both them and the Library together in an executable that you 393 | distribute. 394 | 395 | 7. You may place library facilities that are a work based on the 396 | Library side-by-side in a single library together with other library 397 | facilities not covered by this License, and distribute such a combined 398 | library, provided that the separate distribution of the work based on 399 | the Library and of the other library facilities is otherwise 400 | permitted, and provided that you do these two things: 401 | 402 | a) Accompany the combined library with a copy of the same work 403 | based on the Library, uncombined with any other library 404 | facilities. This must be distributed under the terms of the 405 | Sections above. 406 | 407 | b) Give prominent notice with the combined library of the fact 408 | that part of it is a work based on the Library, and explaining 409 | where to find the accompanying uncombined form of the same work. 410 | 411 | 8. You may not copy, modify, sublicense, link with, or distribute 412 | the Library except as expressly provided under this License. Any 413 | attempt otherwise to copy, modify, sublicense, link with, or 414 | distribute the Library is void, and will automatically terminate your 415 | rights under this License. However, parties who have received copies, 416 | or rights, from you under this License will not have their licenses 417 | terminated so long as such parties remain in full compliance. 418 | 419 | 9. You are not required to accept this License, since you have not 420 | signed it. However, nothing else grants you permission to modify or 421 | distribute the Library or its derivative works. These actions are 422 | prohibited by law if you do not accept this License. Therefore, by 423 | modifying or distributing the Library (or any work based on the 424 | Library), you indicate your acceptance of this License to do so, and 425 | all its terms and conditions for copying, distributing or modifying 426 | the Library or works based on it. 427 | 428 | 10. Each time you redistribute the Library (or any work based on the 429 | Library), the recipient automatically receives a license from the 430 | original licensor to copy, distribute, link with or modify the Library 431 | subject to these terms and conditions. You may not impose any further 432 | restrictions on the recipients' exercise of the rights granted herein. 433 | You are not responsible for enforcing compliance by third parties with 434 | this License. 435 | 436 | 11. If, as a consequence of a court judgment or allegation of patent 437 | infringement or for any other reason (not limited to patent issues), 438 | conditions are imposed on you (whether by court order, agreement or 439 | otherwise) that contradict the conditions of this License, they do not 440 | excuse you from the conditions of this License. If you cannot 441 | distribute so as to satisfy simultaneously your obligations under this 442 | License and any other pertinent obligations, then as a consequence you 443 | may not distribute the Library at all. For example, if a patent 444 | license would not permit royalty-free redistribution of the Library by 445 | all those who receive copies directly or indirectly through you, then 446 | the only way you could satisfy both it and this License would be to 447 | refrain entirely from distribution of the Library. 448 | 449 | If any portion of this section is held invalid or unenforceable under any 450 | particular circumstance, the balance of the section is intended to apply, 451 | and the section as a whole is intended to apply in other circumstances. 452 | 453 | It is not the purpose of this section to induce you to infringe any 454 | patents or other property right claims or to contest validity of any 455 | such claims; this section has the sole purpose of protecting the 456 | integrity of the free software distribution system which is 457 | implemented by public license practices. Many people have made 458 | generous contributions to the wide range of software distributed 459 | through that system in reliance on consistent application of that 460 | system; it is up to the author/donor to decide if he or she is willing 461 | to distribute software through any other system and a licensee cannot 462 | impose that choice. 463 | 464 | This section is intended to make thoroughly clear what is believed to 465 | be a consequence of the rest of this License. 466 | 467 | 12. If the distribution and/or use of the Library is restricted in 468 | certain countries either by patents or by copyrighted interfaces, the 469 | original copyright holder who places the Library under this License may add 470 | an explicit geographical distribution limitation excluding those countries, 471 | so that distribution is permitted only in or among countries not thus 472 | excluded. In such case, this License incorporates the limitation as if 473 | written in the body of this License. 474 | 475 | 13. The Free Software Foundation may publish revised and/or new 476 | versions of the Lesser General Public License from time to time. 477 | Such new versions will be similar in spirit to the present version, 478 | but may differ in detail to address new problems or concerns. 479 | 480 | Each version is given a distinguishing version number. If the Library 481 | specifies a version number of this License which applies to it and 482 | "any later version", you have the option of following the terms and 483 | conditions either of that version or of any later version published by 484 | the Free Software Foundation. If the Library does not specify a 485 | license version number, you may choose any version ever published by 486 | the Free Software Foundation. 487 | 488 | 14. If you wish to incorporate parts of the Library into other free 489 | programs whose distribution conditions are incompatible with these, 490 | write to the author to ask for permission. For software which is 491 | copyrighted by the Free Software Foundation, write to the Free 492 | Software Foundation; we sometimes make exceptions for this. Our 493 | decision will be guided by the two goals of preserving the free status 494 | of all derivatives of our free software and of promoting the sharing 495 | and reuse of software generally. 496 | 497 | NO WARRANTY 498 | 499 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 500 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 501 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 502 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 503 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 504 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 505 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 506 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 507 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 508 | 509 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 510 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 511 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 512 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 513 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 514 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 515 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 516 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 517 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 518 | DAMAGES. 519 | 520 | END OF TERMS AND CONDITIONS 521 | --------------------------------------------------------------------------------